(8/10)

Talking To The Web — Python typing lesson

Make HTTP requests to interact with web APIs.

What you'll practice

Let's talk to the web! We can use the `requests` module to get information from websites and APIs.

  • First, we `import requests`.
  • `requests.get(...)` asks a website for information.

Pro Access Required

This is a premium lesson. Upgrade to Pro to unlock this interactive exercise and continue your learning journey.

🐍Python

Talking To The Web

0 WPM
0% Accuracy
0:00 Time elapsed
1
2
3
4
5
6
7
8
9
import requests↵
↵
response = requests.get('https://uselessfacts.jsph.pl/random.json?language=en')↵
data = response.json()↵
↵
fact = data['text']↵
↵
print('Here is a random fact:')↵
print(fact)
0 / 185
Press This!
👇
`~
1!
2@
3#
4$
5%
6^
7&
8*
9(
0)
-_
=+
⌫
⇥
Q
W
E
R
T
Y
U
I
O
P
[{
]}
\|
⇪
A
S
D
F
G
H
J
K
L
;:
'"
↵
⇧
Z
X
C
V
B
N
M
,<
.>
/?
⇧
Thumb
Index
Middle
Ring
Pinky