A simple wrapper for the requests package
Project description
requestwrapper
A simple wrapper for the Python requests package
Motivation
Common use cases when dealing with requests are:
- handling response errors
- repeating a request until succesfull response
- executing multiple requests
- saving response (html, pdf) to disk
Requestwrapper implements simple methods to perform such tasks without having to write your own code.
Features
- Parameterize HTTP method using the method-argument
- Handle HTTP errors (status_code>299) by returning the raw response instead of json
- Retry failed requests n-times
- Print request-response to console
- Save response content to disk
Prerequisites
- the requests module (https://pypi.org/project/requests/)
Installing
Hosted on PyPI: (https://pypi.org/project/requestwrapper/) With pip: pip install requestwrapper
Usage
import requestwrapper.Request
#initialize the Request object
Request0=requestwrapper.Request.Request()
# workhorse function: send_request
res=Request0.send_request(url='https://nu.nl',method='GET')
# save response content to disk
Request0.save_response('nu.txt')
Examples
TODO
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
requestwrapper-0.0.5.tar.gz
(15.6 kB
view hashes)
Built Distribution
Close
Hashes for requestwrapper-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c1e21ea887ddb3ecebe2574f2068d7fb156c4346d8a5a33b2c8986c3b33af79 |
|
MD5 | 30e25033f7f00d079e8e4468b15d3c77 |
|
BLAKE2b-256 | 03b439085ff6b4acfca129d4b82d01662c0151d1e8805b5d690b04abdb10c806 |