A python network request library that will not throw exceptions
Project description
reqe
A python network request library that will not throw exceptions
Table of Contents
Background
When timeout, network connection error, server error, etc.,
requests will raise the exception, there will be a lot of try ... except ... in the code.
Under the above problems, I developed a reqe based on the requests library, which is as simple as requests
Install
-
source code
git clone git@github.com:ophlr/reqe.git
-
pip
pip install reqe
Usage
import reqe
# use default setting, it can be used like request
response = reqe.get("https://www.baidu.com")
if response:
print(response)
# specify the params that you like
# retries: How many retries, If you don’t want to resend the request, you can set retries to 0
# delay: time between two requests
# backoff: delay = delay * backoff
response = reqe.get("https://www.google.com", retries=3, delay=3, backoff=2)
# when `requests` raises an exception, `reqe` will catch it and let the response be None
if response:
print(response)
# how to use reqe with session
session = reqe.session()
response = session.get("https://www.google.com", retries=1, delay=3, backoff=2)
print(response)
Reference
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reqe-2020.9.17.175617-py3-none-any.whl.
File metadata
- Download URL: reqe-2020.9.17.175617-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce9bd58707f4369d4dbf1de9a93cee841095d91a2294dc5bcbf00a84cbcd9fa2
|
|
| MD5 |
c07bb0da3df5edfdb6c5eafa1531bfe1
|
|
| BLAKE2b-256 |
3d01acd1e7014b1febf4e598bdf2de95ce5620e829bcbae72ec8b6f90ef82240
|