这只是经过验证的答案的更详细版本
如何下载?
pip3 install proxy-requests
基本 GET 请求示例
from proxy_requests import ProxyRequests
r = ProxyRequests("https://dog.ceo/api/breeds/image/random")
r.get()
带有标头的 GET 请求示例
from proxy_requests import ProxyRequests
h = {'User-Agent': 'NCSA Mosaic/3.0 (Windows 95)'}
r = ProxyRequests('url here')
r.set_headers(h)
r.get_with_headers()
POST 请求示例
from proxy_requests import ProxyRequests
r = ProxyRequests('url here')
r.post({'key1': 'value1', 'key2': 'value2'})
带有标头的 POST 请求示例
r = ProxyRequests('url here')
r.set_headers({'name': 'rootVIII', 'secret_message': '7Yufs9KIfj33d'})
r.post_with_headers({'key1': 'value1', 'key2': 'value2'})
带有身份验证的请求示例
r = ProxyRequestsBasicAuth('url here', 'username', 'password')
r.get()
顺便说一句,所有这些东西在Github repository上已经提到了。