blasphemous
Newbie
- Jan 28, 2012
- 2
- 0
Just thought I'd share what I'm working on with y'all. I would greatly appreciate constructive criticism and/or advice on making things work better.
Disclaimer: I just started learning python 2 days ago [25JAN2012 at the time of writing] (and my computer science education ended at the high school level several years ago). As such, please excuse any grievous transgressions I make in speech, implementation, or action.
The following is my attempt at a proxy-checker. I realize that I may just be reinventing the wheel (props to BHW's captchaman for his beautiful Proxy Madness 4), but this particular script is going to be a component in a much larger (and hopefully useful) suite.
More on that later. Sorry about the code not being 100% out-of-the-post functional; I apparently need to wait longer before I can have links in my posts.
Disclaimer: I just started learning python 2 days ago [25JAN2012 at the time of writing] (and my computer science education ended at the high school level several years ago). As such, please excuse any grievous transgressions I make in speech, implementation, or action.
The following is my attempt at a proxy-checker. I realize that I may just be reinventing the wheel (props to BHW's captchaman for his beautiful Proxy Madness 4), but this particular script is going to be a component in a much larger (and hopefully useful) suite.
More on that later. Sorry about the code not being 100% out-of-the-post functional; I apparently need to wait longer before I can have links in my posts.
Code:
# takes untested.txt full of proxies and tries to connect to yahoo.
# if successful, adds it to confirmed.txt and then tries the next one in the list.
# untested.txt's format is one proxy entry per line - ip.ip.ip.ip:port
import socks
class proxyChecker():
def test(self,proxtype):
goodList = open('confirmed.txt', 'w')
for line in open('untested.txt'):
print 'starting new check'
proxy = line.split(':')
pIP = proxy[0]
pPort = int(proxy[1])
if not self.check(proxtype,pIP,pPort):
goodList.write(line)
print 'verified: ', line
goodList.close()
def check(self,proxtype,addr,port):
s = socks.socksocket()
s.setblocking(True)
s.settimeout(10)
if proxtype is 'http':
s.setproxy(socks.PROXY_TYPE_HTTP,addr,port)
elif proxtype is 'socks':
s.setproxy(socks.PROXY_TYPE_SOCKS5,addr,port)
try:
s.connect(("[B]INSERT LINK HERE[/B]",80))
except Exception, detail:
print 'Exception: ', detail
return True
return False
Drone = proxyChecker()
Drone.test('http')
Last edited: