File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,21 @@ I taught this course in my office. You could query the bus and then
150150literally watch it pass by the window out front. Sadly, APIs rarely live
151151forever and it seems that this one has now ridden off into the sunset. --Dave
152152
153+ Update: GitHub user @asett has suggested the following modified code might work,
154+ but you'll have to provide your own API key (available [ here] ( https://www.transitchicago.com/developers/bustracker/ ) ).
155+
156+ ``` python
157+ import urllib.request
158+ u = urllib.request.urlopen(' http://www.ctabustracker.com/bustime/api/v2/getpredictions?key=ADD_YOUR_API_KEY_HERE&rt=22&stpid=14791' )
159+ from xml.etree.ElementTree import parse
160+ doc = parse(u)
161+ print (" Arrival time in minutes:" )
162+ for pt in doc.findall(' .//prdctdn' ):
163+ print (pt.text)
164+ ```
165+
166+ (Original exercise example follows below)
167+
153168Try something more advanced and type these statements to find out how
154169long people waiting on the corner of Clark street and Balmoral in
155170Chicago will have to wait for the next northbound CTA \# 22 bus:
You can’t perform that action at this time.
0 commit comments