requestr
Project description
requestr
A wrapper library for requests, optimised for JSON and HTML
Installation:
pip install requestr
import requestr
url = 'https://jsonplaceholder.typicode.com/posts/1'
response = requestr.get(url)
>>> response.data
{
'userId': 1,
'id': 1,
'title': 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
'body': 'quia et suscipit...'
}
>>> response.data.title
'sunt aut facere repellat provident occaecati excepturi optio reprehenderit'
import requestr
url = 'https://example.com'
response = requestr.get(url)
h1_tag = response.soup.select_one('h1')
>>> h1_tag.text
'Example domain'
from requestr import Session
session = Session()
url = 'https://jsonplaceholder.typicode.com/posts/1'
response = session.get(url)
>>> response.data
{
'userId': 1,
'id': 1,
'title': 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
'body': 'quia et suscipit...'
}
>>> response.data.id
1
from requestr import requestr_futures
from time import sleep
url = 'https://jsonplaceholder.typicode.com/posts/1'
future = requestr_futures.get(url) # Request is executed in background thread without blocking code execution
sleep(3)
response = future.result()
>>> response.data
{
'userId': 1,
'id': 1,
'title': 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
'body': 'quia et suscipit...'
}
>>> response.data.title
'sunt aut facere repellat provident occaecati excepturi optio reprehenderit'
from requestr import FuturesSession
from time import sleep
session = FuturesSession()
url = 'https://jsonplaceholder.typicode.com/posts/1'
response = session.get(url) # Request is executed in background thread without blocking code execution
sleep(3)
response = future.result()
>>> response.data
{
'userId': 1,
'id': 1,
'title': 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
'body': 'quia et suscipit...'
}
>>> response.data.id
1
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_requestr-0.15.tar.gz
(4.7 kB
view details)
File details
Details for the file python_requestr-0.15.tar.gz.
File metadata
- Download URL: python_requestr-0.15.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c410824bb9f88556d1de9a75f62984322d449c2f93e319c4cfc7495ab5f02e7a
|
|
| MD5 |
39ef415d66a284d78e724173ef05d1f6
|
|
| BLAKE2b-256 |
cdf4978458f01e9d8207a512134cb3ecfb9bc27add5c632959b9adece450aac9
|