Skip to content

Instantly share code, notes, and snippets.

@AlexanderFabisch
Created July 24, 2014 06:43
Show Gist options
  • Select an option

  • Save AlexanderFabisch/7561d2fb6a6a94b1d6fe to your computer and use it in GitHub Desktop.

Select an option

Save AlexanderFabisch/7561d2fb6a6a94b1d6fe to your computer and use it in GitHub Desktop.
List Bahn connections
import sys
import json
import requests
def get_suggestions(contains):
r = requests.get("http://reiseauskunft.bahn.de/bin/ajax-getstop.exe/dn?start=1&tpl=sls&REQ0JourneyStopsB=12&REQ0JourneyStopsS0A=1&getstop=1&noSession=yes&iER=yes&S=%s?&js=true" % contains)
res = json.loads(r.text[8:-22])
suggestions = res["suggestions"]
return suggestions
def test_suggestions():
contains = sys.argv[1]
suggestions = get_suggestions(contains)
for s in suggestions:
print "weight:", s["weight"]
print "value:", s["value"]
print "extId:", s["extId"]
print "state:", s["state"]
print "prodClass:", s["prodClass"]
print "xcoord:", s["xcoord"]
print "ycoord:", s["ycoord"]
print "typeStr:", s["typeStr"]
print "type:", s["type"]
print ""
test_suggestions()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment