使用ProxyBroker构建代理池

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)

posted @ 2019-09-11 23:57  hank-li  阅读(696)  评论(0)    收藏  举报