This forum is now read-only. Please use our new forums at discuss.codecademy.com.

How to use APIs with Python Forum

View Course » View Exercise

873 points
E06cf05be64e5f94b616917e0ddd3c7c?s=140&d=retro
Submitted by
Apoc1337
about 4 years ago

Requests: What's wrong here?

from urllib2 import urlopen

# Add your code here!

website = urlopen("http://placekitten.com/")
kittens = website.read()

print kittens[559:1000] 

I cannot figure out why this isn't passing. The interpreter displays "HTTPError: HTTP Error 502: Bad Gateway"; How am I suppose to fix a bad gateway?

Please advise.


5 votes

permalink

Try importing and using request:

from urllib2 import Request, urlopen
request = Request('http://placekitten.com/')

website = urlopen(request)
kittens = website.read()

print kittens[559:1000]

831 points
7f51f13eb5b9fdcfea148bfa73df4c38?s=140&d=retro
Submitted by
sanace
over 3 years ago


0 votes

permalink

Same for me. I tried going directly to placekitten.com in my browser and the host says the site is offline. I'm just going to skip the exercise for now and hopefully it will be up later.

1947 points
87c702bc03fd1ad53704517974dbe1ab?s=140&d=retro
Submitted by
mrerik
about 4 years ago


0 votes

permalink

Yes, unfortunately, I believe the exercise is broken until placekitten.com is updated.

Skipping for now.

Moderator: Please advise when the exercise is back online.

Thanks.

873 points
E06cf05be64e5f94b616917e0ddd3c7c?s=140&d=retro
Submitted by
Apoc1337
about 4 years ago

1 Comment

2cd7e30a4ad66738853941061392035a?s=140&d=retro Perim over 3 years ago

It appears to be working now. Running the code gives me an ascii kitten.


0 votes

permalink

It works fine for me maybe its your browser. I use chrome

1026 points
5261475280ff339827006563_164591793
Submitted by
Bobby Nation
almost 4 years ago


0 votes

permalink

it works for me maby its browser i use firefox

884 points
52a5c9df548c355247001428_819369585
Submitted by
anonymous
about 3 years ago