Last active
August 29, 2015 14:03
-
-
Save jimr/d0539876ff041da8926a to your computer and use it in GitHub Desktop.
Get NextBike rental station numbers for Bath. I'm guessing about the time zone data for when the feed was updated (no docs that I can find).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import sys | |
import urllib2 | |
import xml.etree.ElementTree as ET | |
url = "https://nextbike.net/maps/nextbike-live.xml" | |
stations = sys.argv[1:] | |
xml = urllib2.urlopen(url).read() | |
root = ET.fromstring(xml) | |
places = root.findall(".//city[@alias='bath']/place") | |
for place in places: | |
if not len(stations) or place.get("number") in stations: | |
print "%s: %s (%s)" % ( | |
place.get("name"), place.get("bikes"), place.get("bike_numbers") | |
) | |
date = datetime.datetime.strptime(xml[-25:], '<!-- %d.%m.%Y %H:%M -->') | |
print 'Updated: %s (CET)' % date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment