Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 404 when I try to run the exercise 1.4 #157

Open
ikasovitch opened this issue Dec 24, 2022 · 2 comments
Open

Getting 404 when I try to run the exercise 1.4 #157

ikasovitch opened this issue Dec 24, 2022 · 2 comments

Comments

@ikasovitch
Copy link

Thanks a lot for making this course!!!

It looks like something has changed on the bus tracker website and the example code gets an http return code 404. It seems like the URL should be updated to make the exercise work.

@dabeaz
Copy link
Contributor

dabeaz commented Jan 1, 2023

I've added a note to the exercise about the API being deprecated. Sadly, I don't think I can modify the exercise to make it work as the bus-tracker now requires its users to sign up for an API key.

@asett
Copy link

asett commented May 7, 2023

Hi @dabeaz / @ikasovitch ,

I was able to modify the code for the CTA Bus Tracker and get it to work.
It does require the use of an API key, however it's quite easy to get an API key and then start using the API.

Here's the modified code:

import urllib.request
u = urllib.request.urlopen('http://www.ctabustracker.com/bustime/api/v2/getpredictions?key=ADD_YOUR_API_KEY_HERE&rt=22&stpid=14791')
from xml.etree.ElementTree import parse
doc = parse(u)
print("Arrival time in minutes:")
for pt in doc.findall('.//prdctdn'):
        print(pt.text)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants