How The Internet Works
How The Internet Works
Works
Learning Goals
What
's the
h eadlin
e toda
"Mexica y?
ns Aw
ait Re
sults i
to Firs n Elec
t Fema tion E
le Pre xpecte
sident d to Le
" ad
?
ovies section
a d li ne in the m
he h e
What's t
levate
u n gry to E
aker H lls"
i an Filmm Thri
"A Nig
e r
o l l y wood’s
N
Inspecting these interactions
This is like a
This is like a function call
return value
Inspecting these interactions
This is like a
parameter
This is like a
This is like a function call
return value
What would that function look like?
def get_headline(search)
def get_headline(search)
GET www.nytimes.com/headlines?<search>
Understanding APIs
GET www.nytimes.com/headlines?<search>
GET www.nytimes.com/headlines?<search>
GET www.nytimes.com/headlines?<search>
GET www.nytimes.com/headlines
Get the current headline of the New York Times
GET www.nytimes.com/headlines?section=movies
Get the current headline of the movies section of New York Times
POST www.nytimes.com/comments
Make a comment on an article
How does an API know who you are?
GET www.nytimes.com/headlines?api_key=42§ion=movies
So, how do we do
this in Python?
import requests