I expect the answer to this is “no” but …
Does anyone know if there’s a way to export the data from “my trip” from a mobile pass in some kind of machine-readable form, e.g. something that can be imported into Excel?
I expect the answer to this is “no” but …
Does anyone know if there’s a way to export the data from “my trip” from a mobile pass in some kind of machine-readable form, e.g. something that can be imported into Excel?
Would be interesting indeed to have that. But as far as I know, the only possibilities are "Share as Link” and "Share as image” in the app. Maybe you can do something with "Share as Link”?
Sadly the answer here is “no”. The best we can offer at this point is to take a screen shot or to send the link. I'll pass along this feedback though and keep this thread updated if an exportable PDF function can be implemented - thanks for the suggestion! :)
For anyone reading finding this via search in the future, if you know what you’re doing then you can ‘wget’ the ‘Share as Link’ URL. The resulting HTML file includes the train and trip data in JSON format. It fails the Excel ‘read JSON’ feature but it may be possible to fix that. I’ve not got that far yet.
I build a small python script to extract the the data from the link. It creates a json file from the full data and a csv file with all travels with a couple of attributes including departure and arrival time, origin and destination with country, duration of each travel and the interchanges.
I build a small python script to extract the the data from the link. It creates a json file from the full data and a csv file with all travels with a couple of attributes including departure and arrival time, origin and destination with country, duration of each travel and the interchanges.
Hello pebadu,
Thanks a lot for sharing your python script. I tried to run it a few times, but I keep recieving an error “json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 1994 (char 1993)
” (disclaimer: I’m very new to python, so I might be doing a simple mistake somewhere). I tried to consult the issue with ChatGPT, but it didn’t really help me.
Can I ask you to have a look at the error and possibly indicate where the problem is? Of course only in case you have time and are willing to dedicate some of it to this issue. Perhaps it might be helpful for other in the future :).
I’m copying my python log below (and also attaching as a printscreen).
Note: I found out, that some time after I create the url (with “Share as a link” button in the Interrail app, it expires and doesn’t work anymore. So if anyone reads this some time after being published, it might be better to create your own “fresh” url from the Interrail app, in case you’d like to replicate the case). Thanks upfront!!
C:\WINDOWS\system32>python --version
Python 3.11.5
C:\Milan\Ostatni\Personal\Python>python get_route.py --url "https://share.eurailapp.com/share/trip?id=E3EE9070-885E-11EE-8210-775D46DDAD89&type=list&brand=interrail"
Traceback (most recent call last):
File "C:\Milan\Ostatni\Personal\Python\get_route.py", line 118, in <module>
data = extract_route(args.url)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Milan\Ostatni\Personal\Python\get_route.py", line 14, in extract_route
payload = json.loads(re.findall("payload\s=\s(\{[^;]+);", html)[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mxm\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mxm\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mxm\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 1994 (char 1993)
C:\Milan\Ostatni\Personal\Python>
Hi Milan,
The Regex in extract_route did not handled your payload properly because my assumption was false that a semicolon does not appear in it.
I pushed the bugfix.
For anyone reading finding this via search in the future, if you know what you’re doing then you can ‘wget’ the ‘Share as Link’ URL. The resulting HTML file includes the train and trip data in JSON format. It fails the Excel ‘read JSON’ feature but it may be possible to fix that. I’ve not got that far yet.
Sadly for me the Share as Link functionality does not work for my recent 2.5 month trip, with 149 trains. It says “Something went wrong”. I wonder if that is too much for the app or server to handle? Or just some temporary glitch? Will have to try again in some days. I definitely also would love to be able to download the trip data in some machine-reads format, for possible massaging into interesting visualisation, or just to keep it safe for later perusal.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.