# buspred2.py import urllib from xml.etree.ElementTree import parse busurl = "http://ctabustracker.com/bustime/"\ "map/getStopPredictions.jsp" def bus_predictions(route,stop): fields = {'route': route, 'stop': stop } parms = urllib.urlencode(fields) u = urllib.urlopen(busurl+"?"+parms) doc = parse(u) # Parse XML predictions = doc.findall("//pre/pt") return [p.text for p in predictions] print bus_predictions(6,5037)