Home >  > 抓取可用的代理IP

抓取可用的代理IP

0

抓取https://list.proxylistplus.com/Socks-List-1这里的Socks5代理。

#!/usr/bin/python
import requests
import re
headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:50.0) Gecko/20100101 Firefox/50.0',
}

socks5ip=open("/tmp/socks5.txt","r")
while True:
    line = socks5ip.readline().strip("\n")
    if not line:
        break
    try:
        print "localhost",
        print "-"*5,
        data=requests.get("https://list.proxylistplus.com/Socks-List-1",
                          proxies={"http":"socks5://"+line+""},
                          timeout=15).text
    except:
        print line,
        print "-"*5
    else:
        print line,
        print "-"*5,
        print "https://list.proxylistplus.com/Socks-List-1",
        print ""
        res = re.compile("<tr class=(.*?)</tr>",re.S)
        ret = re.compile("<td>(.*?)</td>")
        for i in xrange(1,len(re.findall(res,data))-1):
            for j in  xrange(1,3):
                print re.findall(ret, re.findall(res, data)[i])[j],
            print ""
        break

用法,先在socks5.txt输入一行IP地址:
Snap338

原载:蜗牛博客
网址:http://www.snailtoday.com
尊重版权,转载时务必以链接形式注明作者和原始出处及本声明。

暧昧帖

本文暂无标签

发表评论

*

*