Skip to content

Instantly share code, notes, and snippets.

@c29r3
Created June 10, 2020 11:35
Show Gist options
  • Save c29r3/facd0187fa186142446a20d82c924c97 to your computer and use it in GitHub Desktop.
Save c29r3/facd0187fa186142446a20d82c924c97 to your computer and use it in GitHub Desktop.
import random
import time
import os
from concurrent.futures import ThreadPoolExecutor
import requests
from requests import RequestException, HTTPError, ConnectionError, Timeout
timeout_req = 10
threads_count = 10000
proxy_path = "socks4.txt"
if os.path.exists(proxy_path):
with open(proxy_path, 'r') as sck4:
proxy_lst = sck4.read().split('\n')
proxy_lst = list(filter(None, proxy_lst))
proxy_len = len(proxy_lst)
else:
proxy_len = 0
sentry_lst = ["a.sentry.testnet.public.bluzelle.com",
"b.sentry.testnet.public.bluzelle.com",
"c.sentry.testnet.public.bluzelle.com",
"d.sentry.testnet.public.bluzelle.com",
"e.sentry.testnet.public.bluzelle.com"]
print(f'Total proxies load: {proxy_len}')
def requester():
headers = {"accept": "application/json"}
try:
sentry = random.choice(sentry_lst)
url = f"http://{sentry}:1317/txs?" \
f"message.action=send&" \
f"message.sender=bluzelle1tuqkgg99m8c0mz9x6ux0vhhy0dpfmcnu56lscq&" \
f"limit=100&page=1"
if proxy_len > 0:
proxy = str(random.choice(proxy_lst)).split(":")
proxies = dict(http=f'socks4://{proxy[0]}:{proxy[1]}',
https=f'socks4://{proxy[0]}:{proxy[1]}')
req = requests.get(url, headers=headers, proxies=proxies, timeout=timeout_req)
# print(req.text)
else:
req = requests.get(url, headers=headers, timeout=timeout_req)
print(f'{time.strftime("%H:%M:%S")} | {req.status_code}')
except (RequestException, HTTPError, ConnectionError, Timeout, Exception) as reqErr:
# print(f'requester() func err: {reqErr}')
pass
while True:
with ThreadPoolExecutor(max_workers=threads_count) as executor:
[executor.submit(lambda: requester()) for i in range(threads_count)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment