Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- from aiohttp import ClientSession
- with open('working-proxies-history.txt') as f:
- proxy_list = [f'http://{proxy}' for proxy in f.read().split()]
- async def fetch(proxy: str):
- async with ClientSession() as s:
- try:
- async with s.get('http://icanhazip.com', proxy=proxy, timeout=6) as r:
- await r.text()
- except:
- return False
- else:
- return True
- async def main():
- step = 400
- count = 0
- for i in range(0, len(proxy_list), step):
- tasks = [
- fetch(proxy)
- for proxy in proxy_list[i:i + step]
- ]
- result = await asyncio.gather(*tasks)
- count += result.count(True)
- print(count)
- asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement