Proxy Checker | Python

Posts 1–2 of 2 · Page 1 of 1
Proxy Checker | Python
This is a short and sweet proxy maker I created in python. It isn't exactly fast or what not but it does the job. I might considering making it faster but until then I wanted to release it to newbs all alike who are interested in python.


If you have python installed save it as proxychecker.py
Code:
Code:
################################
#  MineCraft Proxy Checker     #
#       by WhatsFast           #
################################

#Imports
import urllib2

#Variables
proxyFile = "proxy.txt"
saveToFile = "workingproxy.txt"
proxyList = []

#Check and load proxy file
if os.path.exists(proxyFile):
    handler = open(proxyFile, 'r')
    for proxy in handler.readlines():
        if proxy != "":
            proxyList.append(proxy.strip())
        handler.close()

#Check each proxy
for i in range(len(proxyList)):
    try:
        #If proxy works do this then go to next
        print "Checking: "+proxyList[i]
        proxy  = urllib2.ProxyHandler({'http': proxyList[i]})
        opener = urllib2.build_opener(proxy)
        urllib2.install_opener(opener)
        my_ip = opener.open('http://whatthehellismyip.com/?ipraw').read()
        print proxyList[i]+" works."
        #Save if proxy works
        f = open(saveToFile, 'a')
        f.write(''.join(map(str,{proxyList[i]+"\n"})))
        f.close()
    except:
        #If proxy doesn't work then skip
        print proxyList[i]+" is invalid."
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us