proxybroker2
proxybroker2 copied to clipboard
Serve proxies with one line of code
I think the code to get a list of proxies should be as simple as possible. So just make something like proxies = Broker.get_proxies(n). Maybe an optional parameter with the format of the strings.
def getProxies(n: int) -> List[str]:
'''Return a list of n working proxies
'''
async def show(proxies):
p = []
while True:
proxy = await proxies.get()
if proxy is None: break
p.append(f'{proxy.host}:{proxy.port}')
return p
proxies = asyncio.Queue()
broker = Broker(proxies)
tasks = asyncio.gather(broker.find(types=['HTTPS'], limit=n), show(proxies))
loop = asyncio.get_event_loop()
return loop.run_until_complete(tasks)[1]
@ajr-dev thanks for your feedback :smiley: Would you like to send a PR?