0% found this document useful (0 votes)
11 views2 pages

Requests

Uploaded by

youngboysuy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Requests

Uploaded by

youngboysuy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Requests Library

Requests Library in Python

Overview:

Requests is a simple, yet elegant HTTP library for Python, designed to send HTTP/1.1 requests

easily.

Key Features:

- Sending HTTP/1.1 requests using methods like GET, POST, PUT, DELETE

- Automatic content decoding

- Support for custom headers and sessions

- Built-in JSON decoding

Sample Code:

```python

import requests

# Send a GET request

response = requests.get('https://api.github.com')

# Check status and display content

if response.status_code == 200:

print(response.json())

# Send a POST request


payload = {'key': 'value'}

response = requests.post('https://httpbin.org/post', data=payload)

print(response.text)

```

Use Cases:

- API testing and integration

- Web scraping and automation

- Microservices communication

You might also like