Skip to content

Instantly share code, notes, and snippets.

@skrul
Created November 2, 2010 20:40
Show Gist options
  • Save skrul/660263 to your computer and use it in GitHub Desktop.
Save skrul/660263 to your computer and use it in GitHub Desktop.
import urllib2, socket
import sys
socket.setdefaulttimeout(10)
def is_bad_proxy(pip):
try:
proxy_handler = urllib2.ProxyHandler({'https': pip})
opener = urllib2.build_opener(proxy_handler)
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib2.install_opener(opener)
req=urllib2.Request('https://www.google.com')
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
while 1:
line = sys.stdin.readline()
line = line.strip()
if line == '':
break
print 'Checking %s...' % line
if is_bad_proxy(line):
print '%s is BAD' % line
else:
print '**** %s is GOOD ****' % line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment