bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/Python/Files, Modules, and the Standard Library
Python•Files, Modules, and the Standard Library

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

MethodDescription
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

Previous

Python File Write

Next

How to Add Two Numbers in Python

This chapter

Overview
13

Lessons

39m

Read time

1. Python File Open2. Python Python Built-in Modules3. How to Remove Duplicates From a Python List4. Python File Open5. Python Random Module6. How to Reverse a String in Python7. Python File Write8. Python Requests Module9. How to Add Two Numbers in Python10. Python Delete File11. Python statistics Module12. Python math Module13. Python cmath Module

On this page

Definition and UsageMethods