# Python Proxy Checker (Simple Edition)

**URL:** <https://onehack.st/t/python-proxy-checker-simple-edition/54650>\
**Category:** Tools & Scripts\
**Tags:** privacy\
**Created:** [August 24, 2019, 10:26pm UTC](https://onehack.st/t/python-proxy-checker-simple-edition/54650 "2019-08-24T22:26:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aina](https://onehack.st/user_avatar/onehack.st/aina/32/167469_2.png) [@Aina](https://onehack.st/u/Aina)\
**Post date:** [August 24, 2019, 10:26pm UTC](https://onehack.st/t/python-proxy-checker-simple-edition/54650/1 "2019-08-24T22:26:06Z")

</div>

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

```auto

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! 😊
