Hello ALL, i have some python proxy checker .
and to speed up check, i was decided change to mutlthreaded version, and thread module is first for me, i was tried several times to convert to thread version and look for many info, but it not so much easy for novice python programmar . if anyone can help me really much appreciate!! thanks in advance! import urllib2, socket socket.setdefaulttimeout(180) # read the list of proxy IPs in proxyList proxyList = open('listproxy.txt').read() def is_bad_proxy(pip): try: proxy_handler = urllib2.ProxyHandler({'http': pip}) opener = urllib2.build_opener(proxy_handler) opener.addheaders = [('User-agent', 'Mozilla/5.0')] urllib2.install_opener(opener) req=urllib2.Request('http://www.yahoo.com') # <---check whether proxy alive sock=urllib2.urlopen(req) except urllib2.HTTPError, e: print 'Error code: ', e.code return e.code except Exception, detail: print "ERROR:", detail return 1 return 0 for item in proxyList: if is_bad_proxy(item): print "Bad Proxy", item else: print item, "is working" -- View this message in context: http://old.nabble.com/python-proxy-checker-%2Cchange-to-threaded-version-tp26672548p26672548.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list