I have other method is free method not like proxyscrap. I suggest to use http-request-randomizer from here Link
Using it is so simple
from http_request_randomizer.requests.proxy import RequestProxy
req_proxy = RequestProxy()
pro=req_proxy.randomize_proxy()
pro1=str(pro).split(' ')[0]
Then use pro1 as a proxy for your request it will generate new proxy each time, or if you need to use a custom proxy then:
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.example.com') # change the URL to test here
sock=urllib2.urlopen(req)
except urllib2.HTTPError, e:
print 'Error code: ', e.code
return e.code
except Exception, detail:
print "ERROR:", detail
return True
return False
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…