Login Register


Gold Proxy Checker (Python script) filter_list
Author
Message
Proxy Checker (Python script) #1
I was bored, so I made this Python script that reads a list of proxies from a file and then writes all the still-working proxies to an out file.

Code:
from Queue import Queue from threading import Thread import argparse import requests import sys import time def process_proxy(): try: while True: proxy = queue.get() if proxy == "STOP": return save_valid_proxy(check_proxy(proxy)) queue.task_done() except: pass def check_proxy(proxy, timeout = 5, url = "https://google.com"): proxies = { "http": "http://" + proxy, "https": "https://" + proxy } try: r = requests.get(url, proxies = proxies, timeout = timeout) except IOError: return False return proxy def save_valid_proxy(proxy): if proxy: OUT_F.write(proxy + "\n") if __name__ == "__main__": parser = argparse.ArgumentParser(description = "Check a proxy list for working proxies.") parser.add_argument("infile", help = "The proxy list file.") parser.add_argument("outfile", help = "The output file.") parser.add_argument("-t", "--threads", type = int, help = "Set the number of threads running concurrently.") parser.add_argument("-v", "--verbose", action = "store_true", help = "Be verbose?") args = parser.parse_args() IN_F = open(args.infile, "r") OUT_F = open(args.outfile, "w") # number of threads running at once if args.threads: concurrent_threads = args.threads else: concurrent_threads = 250 if args.verbose: print("Loading proxy list from: {}".format(args.infile)) print("Saving valid proxies list to: {}".format(args.outfile)) print("Running: {} threads...".format(concurrent_threads)) queue = Queue(concurrent_threads * 2) for i in range(0, concurrent_threads): thread = Thread(target = process_proxy) thread.setDaemon(True) thread.start() start = time.time() try: for proxy in IN_F: queue.put(proxy.strip()) # queue.join() except KeyboardInterrupt: pass print("Closing down, please wait. ({} seconds run time)".format(time.time() - start)) queue.put("STOP") IN_F.close() OUT_F.close() sys.exit()

Example usage:
Code:
proxy_checker.py proxylist.txt validproxies.txt --threads 500

If you liked or found this useful, please comment. Smile

[+] 1 user Likes m0dem's post
Reply





Messages In This Thread
Proxy Checker (Python script) - by m0dem - 03-18-2016, 01:01 AM
RE: Proxy Checker (Python script) - by m0dem - 03-19-2016, 11:20 PM
RE: Proxy Checker (Python script) - by Drays - 03-21-2016, 07:35 PM
RE: Proxy Checker (Python script) - by m0dem - 03-21-2016, 09:03 PM
RE: Proxy Checker (Python script) - by Inori - 03-22-2016, 03:53 AM
RE: Proxy Checker (Python script) - by m0dem - 03-22-2016, 05:22 AM
RE: Proxy Checker (Python script) - by m0dem - 03-23-2016, 06:04 AM
RE: Proxy Checker (Python script) - by Drays - 03-24-2016, 12:57 PM
RE: Proxy Checker (Python script) - by m0dem - 03-24-2016, 02:11 PM
RE: Proxy Checker (Python script) - by Inori - 03-24-2016, 02:26 PM
RE: Proxy Checker (Python script) - by m0dem - 03-24-2016, 04:05 PM
RE: Proxy Checker (Python script) - by fsociety - 05-05-2019, 02:49 PM
RE: Proxy Checker (Python script) - by Drako - 05-05-2019, 05:04 PM



Users browsing this thread: 1 Guest(s)