jeudi 17 mars 2022

Why aiohttp-socks does not accept the value that was retrieved by using random library?

import aiohttp
import asyncio
import random
from aiohttp_socks import ProxyType, ProxyConnector, ChainProxyConnector

_goodsocks = []
_loop = asyncio.get_event_loop()

for socks in open("C:\\Users\\user\\Desktop\\python\\goodsocks.txt","r").read().split("\n"):
    _goodsocks.append(socks)

async def randomfunction():
    conn = ProxyConnector.from_url(f"socks5://{str(random.choice(_goodsocks))}")
    session = await createsession(conn)
    response = await session.get("http://www.google.com")
    print(response.status)

i = 0
while i <= 10:
    loop.create_task(randomfunction())

try:
    loop.run_forever()
except:
    loop.stop()
finally:
    loop.close()

output:

conn = ProxyConnector.from_url(f"socks5://{prox}")

proxy_type, host, port, username, password = parse_proxy_url(url)

raise ValueError('Empty host component')  # pragma: no cover

ValueError: Empty host component

**Im trying to send a request with a random proxy. Im able to send the request by typing manually the host and port but when i use the random library it gives a error that says empty host component. **




Aucun commentaire:

Enregistrer un commentaire