跳转到主要内容

使用requests的WSGI代理

项目描述

使用requests的WSGI代理。

安装

使用pip

$ pip install requests_proxy

用法

创建代理

>>> from requests_proxy import Proxy
>>> proxy = Proxy(application_url)

然后使用它。这里是一个使用WebOb的示例,但你也可以像经典WSGI应用程序一样使用它

>>> from webob import Request
>>> req = Request.blank('/form.html')
>>> resp = req.get_response(proxy)
>>> print(resp.text)
<html>...
...</html>

代理应用程序接受一些关键字参数。这些参数在请求过程中传递。默认情况下 allow_redirectsverify 设置为 False,但你可以更改行为

>>> proxy = Proxy(application_url, verify=True, allow_redirects=True, max_redirects=10)

谢谢

变更

0.1

首次公开发布

支持