Skip to main content

requestr

Project description

requestr

A wrapper library for requests, optimised for JSON and HTML

Installation: pip install python-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.16.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file python_requestr-0.16.tar.gz.

File metadata

  • Download URL: python_requestr-0.16.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

Hashes for python_requestr-0.16.tar.gz
Algorithm Hash digest
SHA256 656bcd451df7036dde76c693ea47b22f6b3eb183085b1cfac9dcdec28e6a64da
MD5 e8ed2bac2cfbb55d70c2537d641812f5
BLAKE2b-256 692c8f141fab659ff60818cf7f19b6d84e3bc38a69b3f5794e47f7b317dc89fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page