Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

python check a list of proxies for working ones

pretty basic but it does have 3 special features, duplicate prevention, redirect check, and timeout of 8 seconds
Code
#!/usr/bin/python
import urllib2, threading
plist = "./proxies.txt"
proxies = open(plist, "r").readlines()
for ip in proxies:
    ip = ip.replace('\n', '').replace(' ', '').replace('\t', '')
    print 'Trying %s ...' % ip
    try:
        proxy_handler = urllib2.ProxyHandler({'http': ip})
        opener = urllib2.build_opener(proxy_handler)
        opener.addheaders = [('User-agent', 'Mozilla/5.0')]
        urllib2.install_opener(opener)
        req = urllib2.urlopen('http://www.google.com', timeout=8)
        if "google" in req.geturl():
            qwerty = open('./working-proxies.txt').read()
            if (ip not in qwerty):
                print '%s is OK, saved' % ip
                f = open("./working-proxies.txt", "a")
                f.write(ip + "\n")
                f.close()
            else:
                print 'duplicate prevented'
        else:
            print 'some kind of bullshit redirect'
    except urllib2.HTTPError:
        print 'http error'
    except Exception:
        print 'unknown error'
This is pretty nice, thanks a lot for sharing.

Hey there,
If I have helped you or if you just enjoy my posts, please consider donating bitcoin to me 1DpL2kcxuidEsjt2MMN2AYufcVoXbi3v2X

[Image: FtwuQgr.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by FudsterMay 1, 2020 06:56 PM 2 135 May 1, 2020 06:56 PM
Last Post: ihatevim
[Python] by vorticalboxJul 22, 2017 10:48 AM 4 158 Jul 22, 2017 10:48 AM
Last Post: vorticalbox