OP 05 January, 2023 - 12:36 PM
(This post was last modified: 05 January, 2023 - 02:37 PM by PepeArgento. Edited 3 times in total.)
I am working on an asynchronous proxy checker and when it has to test many proxies the script never works.
when there are few proxies, it works.
async def check(client, proxy):
url = 'http://www.google.com/'
proxies = ('http://' + proxy)
try:
r = await client.get(url, proxy=proxies, timeout=10)
r.close()
print(f'''G00D {proxy}''')
return proxy
except:
pass
async def check1():
async with sem:
async with aiohttp.ClientSession() as client:
tasks = []
g00d = []
for proxy in protsies:
task = asyncio.ensure_future(check(client, proxy))
tasks.append(task)
results = await asyncio.gather(*tasks)
for proxy in results:
if proxy != None:
g00d.append(proxy)
return g00d
IGNORE VARIABLE NAMES
when there are few proxies, it works.
async def check(client, proxy):
url = 'http://www.google.com/'
proxies = ('http://' + proxy)
try:
r = await client.get(url, proxy=proxies, timeout=10)
r.close()
print(f'''G00D {proxy}''')
return proxy
except:
pass
async def check1():
async with sem:
async with aiohttp.ClientSession() as client:
tasks = []
g00d = []
for proxy in protsies:
task = asyncio.ensure_future(check(client, proxy))
tasks.append(task)
results = await asyncio.gather(*tasks)
for proxy in results:
if proxy != None:
g00d.append(proxy)
return g00d
IGNORE VARIABLE NAMES