def proxy(): logging.basicConfig() pl = ProxyList() try: pl.load_file(proxyList) except: sys.exit('\033[1;31m[!] Proxy File format has incorrect | EXIT...\033[1;31m') pl.random() getProxy = pl.random().address() b.set_proxies(proxies={"https": getProxy}) try: checkProxyIP = b.open("https://api.ipify.org/?format=raw", timeout=2) except: return proxy()
class ProxyMiddleware(object): def __init__(self): self.pl = ProxyList() self.pl.load_file(os.path.join(BASE_DIR, 'proxy/proxylist.txt')) def process_request(self, request, spider): request.meta['proxy'] = 'http://{}'.format(self.pl.random().address())
def proxy(): logging.basicConfig() pl = ProxyList() try: pl.load_file(proxyList) except: sys.exit( "[!] Proxy file wasn't found, please use -X and specify a proxy file." ) pl.random() getProxy = pl.random().address() brows.set_proxies(proxies={"https": getProxy}) # skips bad proxies (10 seconds is the limit for the proxy) try: checkProxyIP = brows.open("https://api.ipify.org/?format=raw", timeout=10) except: return proxy()
def proxy(): pl = ProxyList() try: pl.load_file(proxyList) except: fox.shutdown() sys.exit( '\033[1;31m[!] Proxy File format incorrect | EXIT...\033[1;31m') try: fox.setProxy(pl.random().address()) time.sleep(5) fox.printProxy() except Exception as e: print("\033[1;31m[!] RETRY NEW PROXY...\033[1;31m") return proxy()
return SEND_URL open_useragents() ##TODO: check if Tor is already running and return that as process id, or ## terminate the process and start a new one # requirements.txt #start_tor(USE_TORRC) start = time.time() req_proxy = ProxyList() req_proxy.load_file('proxy_formatted.txt') for x in range(0, len(req_proxy)): try: output = push_vote(POLL_NUM, POLL_OPTION, req_proxy.random().address()) except requests.exceptions.ProxyError: cprint("Dead Proxy :(", 'red', 'on_white') except requests.exceptions.ConnectionError: cprint("Proxy can't talk to PollDaddy :(", 'red', 'on_white') except AttributeError: cprint("Proxy request timed out :(", 'red', 'on_white') except requests.exceptions.ReadTimeout: cprint("Vote request timed out :(", 'red', 'on_white') else: pass revote_status = "revoted" in output.url #print output.url if "voted" in output.url: if (revote_status == 0): cprint(
from selenium import webdriver from selenium.webdriver import DesiredCapabilities import pickle from proxylist import ProxyList pl = ProxyList() pl.load_file('./web/proxy.txt') proxy = pl.random().address() print(proxy[1:-5]) from selenium.webdriver.chrome.options import Options # from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.proxy import Proxy, ProxyType prox = Proxy() prox.proxy_type = ProxyType.MANUAL prox.http_proxy = proxy prox.socks_proxy = proxy prox.ssl_proxy = proxy capabilities = webdriver.DesiredCapabilities.CHROME prox.add_to_capabilities(capabilities) # firefox_capabilities = DesiredCapabilities.FIREFOX # firefox_capabilities['marionette'] = True # firefox_capabilities['binary'] = '/usr/bin/firefox' # chrome_options = Options() # chrome_options.add_argument("user-data-dir=selenium")