.. image:: https://img.shields.io/pypi/v/proxybroker.svg?style=flat-square :target: https://pypi.python.org/pypi/proxybroker/ .. image:: https://img.shields.io/travis/constverum/ProxyBroker.svg?style=flat-square :target: https://travis-ci.org/constverum/ProxyBroker .. image:: https://img.shields.io/pypi/wheel/proxybroker.svg?style=flat-square :target: https://pypi.python.org/pypi/proxybroker/ .. image:: https://img.shields.io/pypi/pyversions/proxybroker.svg?style=flat-square :target: https://pypi.python.org/pypi/proxybroker/ .. image:: https://img.shields.io/pypi/l/proxybroker.svg?style=flat-square :target: https://pypi.python.org/pypi/proxybroker/
ProxyBroker 是一个开源工具,它能异步地从多个来源查找公共代理,并同时对其进行检测。
.. * 将找到的代理保存为自定义格式的文件。
aiohttp <https://pypi.python.org/pypi/aiohttp>_aiodns <https://pypi.python.org/pypi/aiodns>_maxminddb <https://pypi.python.org/pypi/maxminddb>_安装来自 pypi 的最新稳定版本:
.. code-block:: bash
$ pip install proxybroker
最新的开发版本可直接从 GitHub 安装:
.. code-block:: bash
$ pip install -U git+https://github.com/constverum/ProxyBroker.git
命令行示例
查找
""""
查找并显示来自美国的 10 个高匿名 HTTP(S) 代理:
.. code-block:: bash
$ proxybroker find --types HTTP HTTPS --lvl High --countries US --strict -l 10
.. image:: https://raw.githubusercontent.com/constverum/ProxyBroker/master/docs/source/_static/cli_find_example.gif
获取
""""
查找并将 10 个美国代理保存到文件(不经检测):
.. code-block:: bash
$ proxybroker grab --countries US --limit 10 --outfile ./proxies.txt
.. image:: https://raw.githubusercontent.com/constverum/ProxyBroker/master/docs/source/_static/cli_grab_example.gif
服务
"""""
运行一个本地代理服务器,将传入请求分发到已找到的高匿名 HTTP(S) 代理池中:
.. code-block:: bash
$ proxybroker serve --host 127.0.0.1 --port 8888 --types HTTP HTTPS --lvl High
.. image:: https://raw.githubusercontent.com/constverum/ProxyBroker/master/docs/source/_static/cli_serve_example.gif
| 运行 ``proxybroker --help`` 可查看可用选项的详细信息。
| 运行 ``proxybroker <command> --help`` 可查看某个命令的详细信息。
基础代码示例
查找并显示 10 个可用的 HTTP(S) 代理:
.. code-block:: python
import asyncio
from proxybroker import Broker
async def show(proxies):
while True:
proxy = await proxies.get()
if proxy is None: break
print('Found proxy: %s' % proxy)
proxies = asyncio.Queue()
broker = Broker(proxies)
tasks = asyncio.gather(
broker.find(types=['HTTP', 'HTTPS'], limit=10),
show(proxies))
loop = asyncio.get_event_loop()
loop.run_until_complete(tasks)
更多示例 <https://proxybroker.readthedocs.io/en/latest/examples.html>_.
https://proxybroker.readthedocs.io/
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-feature基于 Apache 许可证 2.0 版本授权
本产品包含 MaxMind 创建的 GeoLite2 数据,可从 http://www.maxmind.com <http://www.maxmind.com>_ 获取。