Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Python Requests Module?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ requests3Order
Put the learning moves in the order that makes the concept easiest to apply.
Make a request to a web page, and print the response text:
Definition and Usage
Python Requests Module
Example
Make a request to a web page, and print the response text:
import requests
x = requests.get('https://example.com
print(x.text)Definition and Usage
The requests module allows you to send HTTP requests using Python.
The HTTP request returns a Response Object with all the response data (content, encoding, status, etc).
Syntax
requests.
methodname(params)Methods
| Method | Description |
|---|---|
| delete( url , args ) | Sends a DELETE request to the specified url |
| get( url , params, args ) | Sends a GET request to the specified url |
| head( url , args ) | Sends a HEAD request to the specified url |
| patch( url , data, args ) | Sends a PATCH request to the specified url |
| post( url , data, json, args ) | Sends a POST request to the specified url |
| put( url , data, args ) | Sends a PUT request to the specified url |
| request( method , url , args ) | Sends a request of the specified method to the specified url |