Comments (15)
The last time I had parsing issues with this library I rewrote Schiene to use the HAFAS api (thanks for your hafas-client @derhuerst) but keep the same functions and their signatures so it works as a drop in replacement.
Maybe you have use for this: https://github.com/dominik-th/schiene2
Sample output of a connection with delay:
https://gist.githubusercontent.com/dominik-th/ad403c54fc0852952688eb0bc3ed9a05/raw/1b5db3cdc1ccd5e5befbd7fa0d07dac235842e6c
(I've never worked with python before, so please take a look on the code and fix things if you find anything)
from schiene.
It looks like some reason a different HTML source code is returned when the search involves Hansaring, Köln
as the destination station. When it is the origin station, it seems to work fine.
Edit: It looks like this bug only occurs in the latest release 0.21
. The previous release 0.20
seems to give the correct result. So i guess the bug was introduced in this pull request here: #13. Unfortunately i currently do not have the time to dig deeper right now. Perhaps @akloeckner can take a look at this?
As a temporary workaround i suggest downgrading to 0.20
.
from schiene.
Hm, according to https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/deutsche_bahn.py, version 0.20 is specified already?
from schiene.
… also, it’s currently working again.
from schiene.
I have the same problem for a connection inside of bonn and pinpointed the problem. It seems if you load the detail page for a connection, it opens collapsed for connections inside the same network/"verbund" (vrs/bonn for me).
Compare !details=opened!
in the detail page url
to !details=opened!detailsVerbund=opened!
in detail page url
This also fixed Leverkusen Mitte to Köln Hansaring (also vrs) as it is the same error, I just did a quick hack and did a search replace for the parameters in the url, will send a pull request.
from schiene.
Merged fix from @mkuhlmann and released new package on PyPI as version 0.22
from schiene.
Hey guys,
I've installed version 0.22 but the bug seem to persist for some connections.
Since I've just searched for a connection with delay I found this:
`
import schiene
s = schiene.Schiene()
s = s.connections('Augsburg','Augsburg-Oberhausen')
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/.local/lib/python3.5/site-packages/schiene/schiene.py", line 135, in connections
return parse_connections(rsp.text)
File "/home/pi/.local/lib/python3.5/site-packages/schiene/schiene.py", line 35, in parse_connections
data = parse_delay(data)
File "/home/pi/.local/lib/python3.5/site-packages/schiene/schiene.py", line 65, in parse_delay
delay_arrival_raw = soup.find('div', class_="routeEnd").find('span', class_=["delay", "delayOnTime"])
AttributeError: 'NoneType' object has no attribute 'find'
`
Maybe the html helps you debugging:
bahn.html.zip
from schiene.
Hey!
A while ago I've written hafas-client
, a JavaScript client for the HAFAS mgate.exe
APIs used by e.g. the DB app. public-transport-enabler
, the open source core behind the Öffi app also supports it.
It would be cool to build a Python port/clone, so that all of you can fetch HAFAS data from the environment you use. Let me know if you need assistance.
from schiene.
The last time I had parsing issues with this library I rewrote Schiene to use the HAFAS api (thanks for your hafas-client @derhuerst) but keep the same functions and their signatures so it works as a drop in replacement.
I appreciate the effort, but arguably it's lacking quite a few features. If you want, we can make this a fully featured client.
from schiene.
Thanks to you both!
Nice to hear that there are some projects going on at the moment - and that they are not relying on parsing HTML. :D
I will try schiene2 and have a look on the JS-hafas-client. But I think schiene2 will already serve my demands on just displaying the next few departures with delays (and I need it in python).
from schiene.
I will try schiene2 and have a look on the JS-hafas-client. But I think schiene2 will already serve my demands on just displaying the next few departures with delays (and I need it in python).
Keep in mind that schiene2
doesn't (seem to) handle all edge cases, even when just fetching departures.
from schiene.
Yeah I've just seen that while playing around a little. One connection that was canceled was not marked so in the output for example. Let's see what further investigations will show.
Unfortunately I'm a python noob, otherwise I would offer my help!
from schiene.
Another shameless plug: You can always use our public API wrapping the DB HAFAS endpoint. (This of course adds one more centralised component to the system.)
from schiene.
I personally think that another server dependency wouldn't be the perfect choice. Another library dependency wouldn't hurt probably.
Assuming DB's API will stay around, I have the impression, your JS implementation of the API is quite sophisticated. So, I wonder wouldn't it be possible to simply wrap it in Python (instead of porting it)? That way, API changes on the DB side would need handling only once.
A quick look around pointed me to JS2PY. It is said to interpret virtually any JS code. What do you think? Schiene3 is coming? ;-)
https://pypi.org/project/Js2Py/
PS: For reference, there is an issue for this subject already: #1
PPS while we're at it. Why not simply include the (Java) implementation of transport-enabler, which you mentioned? We could simply plug into an (apparently?) proven open-source backend...
from schiene.
I've proceeded with the discussion in
#1 (comment).
from schiene.
Related Issues (20)
- Not getting the next train correctly HOT 3
- Requirement "lxml" missing HOT 1
- Schiene fails to convert price to float HOT 4
- "delay" not working HOT 5
- There is a Bahn api now HOT 8
- HTML Code changed? HOT 1
- Problem with Wolfbusch Station HOT 2
- "self.data.update & self.only_direct" in update HOT 2
- Duration not accurate if >24 hours HOT 1
- Better Alternative HOT 1
- Is there a limit to requests / seconds? HOT 2
- Parallel? HOT 1
- Hamburg-Eidelstedt not working HOT 2
- schiene crashes HOT 2
- Help with use HOT 1
- TypeError: unsupported operand type HOT 2
- Use pyhafas HOT 10
- Bahn declares cancelled train wrong?
- Canceled connection is reported as 'ontime'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schiene.