Git Product home page Git Product logo

Comments (15)

dominik-th avatar dominik-th commented on August 25, 2024 5

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.

kennell avatar kennell commented on August 25, 2024

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.

PattaFeuFeu avatar PattaFeuFeu commented on August 25, 2024

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.

PattaFeuFeu avatar PattaFeuFeu commented on August 25, 2024

… also, it’s currently working again.

from schiene.

mkuhlmann avatar mkuhlmann commented on August 25, 2024

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
detailsopened

to !details=opened!detailsVerbund=opened! in detail page url
detailsverbundopened

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.

kennell avatar kennell commented on August 25, 2024

Merged fix from @mkuhlmann and released new package on PyPI as version 0.22

from schiene.

lud-hu avatar lud-hu commented on August 25, 2024

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'

`

bildschirmfoto 2018-12-02 um 21 34 35

Maybe the html helps you debugging:
bahn.html.zip

from schiene.

derhuerst avatar derhuerst commented on August 25, 2024

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.

derhuerst avatar derhuerst commented on August 25, 2024

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.

lud-hu avatar lud-hu commented on August 25, 2024

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.

derhuerst avatar derhuerst commented on August 25, 2024

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.

lud-hu avatar lud-hu commented on August 25, 2024

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.

derhuerst avatar derhuerst commented on August 25, 2024

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.

akloeckner avatar akloeckner commented on August 25, 2024

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.

derhuerst avatar derhuerst commented on August 25, 2024

I've proceeded with the discussion in
#1 (comment).

from schiene.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.