Moin, nichts großartiges, hatte ich mal eines Tages geschrieben und musste feststellen das ich es gerne in andere kleinen Projekte nutze.
Vielleicht für den ein oder anderen nützlich zum lernen oder sonstiges =)
import socket #Le1ght Lil'Proxy-checker class ProxyChecker(): def __init__(self): print("Initialize Proxy Checker...") def CheckProxy(self): 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): #print("Nope") pass else: self.AddProxy(ipAddress + ":" + str(port)) 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()
Beispiel proxylist.txt:
105.236.248.219:3123 104.236.248.219:3128 108.61.159.164:8080 104.248.53.46:3128 104.152.45.45:80 104.152.45.46:80 104.168.211.80:8080 103.89.253.249:3128 104.248.184.16:8080 103.89.253.246:3128 103.35.64.12:3128 103.87.78.123:3128 103.84.173.7:3128 103.231.242.242:80 106.2.238.2:3128 103.204.78.138:80 103.112.212.30:83 109.68.41.78:8080 103.41.212.186:8080 101.51.108.101:8080 101.51.246.159:8080 1.10.138.224:8080 103.245.198.101:8080 1.10.244.125:8080 101.4.136.34:8080 101.4.136.34:81