Python Projects & Skills / The web and automation
Lesson 17 of 28
HTTP requests with requests
The requests library fetches web pages and talks to APIs in one line.
Key points
- requests.get(url)
- .status_code, .text, .json()
- Always set a timeout
import requests
r = requests.get("https://api.github.com", timeout=10)
print(r.status_code)Quiz · +10 XP
What status code means a request succeeded?
Log in to save progress and earn XP.