Created
May 12, 2014 05:18
-
-
Save JakenHerman/7824f380451d1d8acdbc to your computer and use it in GitHub Desktop.
This file contains 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
__author__ = 'Jaken' | |
import urllib | |
import webbrowser | |
from xml.etree.ElementTree import parse | |
lat = 41.980262 | |
lon = -87.668452 | |
u = urllib.urlopen('http://ctabustracker.com/bustime/map/getBusesForRoute.jsp?route=22') | |
data = u.read() | |
f = open('rt22.xml', 'wb') | |
f.write(data) | |
f.close() | |
doc = parse('rt22.xml') | |
for bus in doc.findall('bus'): | |
latBus = float(bus.findtext('lat')) | |
lonBus = float(bus.findtext('lon')) | |
if latBus > lat: | |
direction = bus.findtext('d') | |
if direction.startswith('South'): | |
busid = bus.findtext('id') | |
print busid, latBus | |
webbrowser.open_new("http://maps.googleapis.com/maps/api/staticmap?center="+latBus+","+lonBus+"&zoom=12&size=400x400&sensor=false") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment