Python Proxy Checker (Simple Edition)

Save the proxies like that in the proxylist.txt (File format: IP:PORT)



import socket
import os.path
class ProxyChecker():

    def __init__(self):
        print("Starting the checker...")


    def CheckProxy(self):
        try:
            with open('proxylist.txt', 'r+') as f:
                for line in f.readlines():
                    ipAddress = str.split(line, ':')[0]
                    port = str.split(line, ':')[1]
                    proxyIP = (ipAddress, int(port))
                    s = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
                    s.settimeout(5)
                    print("[!] - Checking {} ...".format(proxyIP))
                    if s.connect_ex(proxyIP):
                        pass
                    else:
                        self.AddProxy(ipAddress + ":" + str(port))
        except IOError:
            print('proxylist.txt not found')



    def AddProxy(self, proxyAddress):
        with open('positive.txt', 'a') as f:
            #Duplicate Check:
            with open('positive.txt', 'r+') as r:
                if proxyAddress in r.readlines():
                    print("[!] - {} already added!".format(proxyAddress))
                else:
                    print("[+] - {} added!".format(proxyAddress))
                    f.write(proxyAddress)


if __name__ == "__main__":
    ProxyChecker().CheckProxy()

ENJOY! :blush:

11 Likes