you know what just use requests library, it isnt the fastest but atleast it supposrts…
- User
you know what just use requests library, it isnt the fastest but atleast it supposrts socks5, make sure to add the prefix of socks5:// aswell
import asyncio import httpx import threading
async def fetch_proxies(): proxy_url = ‘https://api.proxyscrape.com/?request=getproxies&proxytype=socks5&timeout=10000&ssl=yes’ async with httpx.AsyncClient() as client: response = await client.get(proxy_url) return response.text.splitlines()
async def fetch_data(url, headers, proxy): transport = AsyncProxyTransport.from_url(url=proxy) async with httpx.AsyncClient(transport=transport, headers=headers) as client: response = await client.get(url) return response.text
def threaded_fetch_data(url, headers, proxy, results, user_agent, lock): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) data = loop.run_until_complete(fetch_data(url, headers, proxy)) with lock: results[user_agent] = data
async def main(): url = ‘https://se1zed.cc/’ headers_file = ‘user_agents.txt’
Fetch proxies from ProxyScrape
proxies = await fetch_proxies()
if not proxies: print(‘No proxies found.’) exit() else: print(str(len(proxies)) + " proxies found")
Read user agents from file
with open(headers_file, ‘r’) as file: user_agents = [line.strip() for line in file if line.strip()]
if not user_agents: print(‘No user agents found.’) exit() else: print(str(len(user_agents)) + " UAs found")
results = {} lock = threading.Lock() tasks = []
Iterate over user agents and proxies simultaneously
for user_agent, proxy in zip(user_agents, proxies): headers = {‘User-Agent’: user_agent} task = threading.Thread(target=threaded_fetch_data, args=(url, headers, “socks://”+proxy, results, user_agent, lock)) tasks.append(task) task.start()
Wait for all threads to finish
for task in tasks: task.join()
print(‘Results:’) for user_agent, data in results.items(): print(f"User-Agent ‘{user_agent}’ - Data: {data}")
asyncio.run(main())
- Assistant