requestspr
在启动了Clash的情况下,requests发送请求会报错,于是稍微封装了下
Install
pip install requestspr
Example
from requestspr import Requests, ProxyMode
def twitter():
"""请求推特页面"""
try:
return requests.get('https://twitter.com/')
except Exception as e:
return e
if __name__ == '__main__':
# 在开着Clash的情况下
requests = Requests()
# 获取代理信息
print(requests.get_proxies())
# 默认使用系统代理, 请求成功
print(twitter())
# 不使用系统代理,请求超时
requests.set_proxy_mode(ProxyMode.NoProxy)
print(twitter())
# 自行设置代理
requests.set_proxy_mode(ProxyMode.Static, {'https': '127.0.0.1:7890'})
print(twitter())
Metadata
Release files for requestspr 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| requestspr-0.0.3.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| requestspr-0.0.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / requestspr-0.0.3.tar.gz
| Download URL | requestspr-0.0.3.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9e368ebfd828f21ab90f5a05ec8f879967ea12c44be8d7a713ff2319b68946b
|
|
BLAKE2b-256 checksum How to use checksums |
8f9adea62072d5a85c169dc10d7329259051a416651462e42ea896042ab9f2e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.2
|
Release files / requestspr-0.0.3-py2.py3-none-any.whl
| Download URL | requestspr-0.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
11957e9dd8e86c9a0c8fba78d14b309a308ed7108c37a9572133a898af335ce4
|
|
BLAKE2b-256 checksum How to use checksums |
0007a6bf4364d1cc8a16a0a197b36960eb222dc57844e0c70fa601ae76e0ff0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.2
|