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

1697 points
Picture
Submitted by
Nick Zink
over 4 years ago

6/20 How to make a GET request?

import requests

kittens = requests.get(http://placekitten.com/)

print kittens.text[559:1000]

8 votes

permalink

You are missing the quotes around the website name.

kittens = requests.get('http://placekitten.com/')

1454 points
A12beb37a2f7095c0f6dfb3d2545f301?s=140&d=retro
Submitted by
JScruffy
over 4 years ago

3 Comments

Picture Chad Elliott almost 4 years ago

That's exactly what I have, and my code still isn't submitting

53888fa280ff3325790030a1_138435731 hatcat over 3 years ago

it works

5343ce9b282ae3614700222d_704354971 JViciouz over 2 years ago

I had the same code, I just forgot an "s".Thanks


3 votes

permalink

import requests

kittens = requests.get('http://placekitten.com/')

print kittens.text[559:1000]

990 points
5406b93f548c3592e0000bf4_438192580
Submitted by
Cousins
almost 4 years ago

1 Comment

54b669999376763f0f005567_56136766 Thibault Watteeuw over 3 years ago

thanks !


0 votes

permalink

its still not working..:(

474 points
488ec5f5272ac1aa5fedfdf0a8425ec8?s=140&d=retro
Submitted by
Smriti Priya
about 4 years ago

2 Comments

595685279ad7f5be150002c6_951960925 mezbah alam almost 4 years ago

I am not sure about your problem . but in this exercise you only need :

  1. creating variable named kittens. 2.then assign it with the result of get() method of requests. ex: requests.get('http://placekitten.com/')

5221a0a780ff33cbb900052b_894281508 Ⓩⓐⓘⓓⓗⓐⓐⓝ over 3 years ago

import requests

kittens = requests.get('http://placekitten.com/')

print kittens.text[559:1000]


0 votes

permalink

you forgot the semicolon at the end of kittens = requests.get('http://placekitten.com/')

1387 points
54f47f79e39efe646d00727f_646434108
Submitted by
Hunter Steele
almost 3 years ago