Bin ein ziemlicher Anfänger, mal gleich vorneweg

Code: Alles auswählen
import urllib2, threading
url = urllib2
class SocketThread(threading.Thread):
def __init__ (self, proxy):
self.proxy = proxy
threading.Thread.__init__ (self)
def run(self):
self.proxy = self.proxy.rstrip()
self.proxy = self.proxy.replace(" ", "")
proxysupport = urllib2.ProxyHandler({"http" : self.proxy})
opener = urllib2.build_opener(proxysupport)
urllib2.install_opener(opener)
Request = urllib2.Request("http://www.google.de")
try:
try:
open = urllib2.urlopen(Request)
print "== " + self.proxy + "\t\t== Works!"
open.close()
except (socket.error,httplib.CannotSendRequest,httplib.ResponseNotReady,httplib.BadStatusLine):
print "== " + self.proxy + "\t\t== Can't request"
except url.URLError, e:
ErrorString = str(e)
if "timed out" in ErrorString:
print "== " + self.proxy + "\t\t== Timed out!"
elif "111" in ErrorString:
print "== " + self.proxy + "\t\t== Connection refused!"
elif "113" in ErrorString:
print "== " + self.proxy + "\t\t== No route to host!"
elif "503" in ErrorString:
print "== " + self.proxy + "\t\t== Service unavailable!"
elif "404" in ErrorString:
print "== " + self.proxy + "\t\t== Not found!"
elif "400" in ErrorString:
print "== " + self.proxy + "\t\t== Bad request!"
elif "50" in ErrorString:
print "== " + self.proxy + "\t\t== Proxy error!"
elif "403" in ErrorString:
print "== " + self.proxy + "\t\t== Forbidden!"
elif "401" in ErrorString:
print "== " + self.proxy + "\t\t== Authorization required!"
else:
print "== " + self.proxy + "\t\t== Unknown!"
proxylist = open("1.txt", "r")
for line in proxylist:
SocketThread(line).start