warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
阅读:2409回复:19

有没有批量抓取并验证而且自动导入到代理的扩展

楼主#
更多 发布于:2017-02-09 12:44
 http://www.xicidaili.com/nn/这么多一个个弄太麻烦了。要是有扩展可以批量导入就好了
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
1楼#
发布于:2017-02-09 12:45
批量获取from bs4 import BeautifulSoup
import urllib2


of = open('proxy.txt' , 'w')

for page in range(1, 160):
    html_doc = urllib2.urlopen('http://www.xici.net.co/nn/' + str(page) ).read()
    soup = BeautifulSoup(html_doc)
    trs = soup.find('table', id='ip_list').find_all('tr')
    for tr in trs[1:]:
        tds = tr.find_all('td')
        ip = tds[1].text.strip()
        port = tds[2].text.strip()
        protocol = tds[5].text.strip()
        if protocol == 'HTTP' or protocol == 'HTTPS':
            of.write('%s=%s:%s\n' % (protocol, ip, port) )
            print '%s=%s:%s' % (protocol, ip, port)

of.close()
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
2楼#
发布于:2017-02-09 12:46
接着验证代理是否可用#encoding=gbk
import httplib
import time
import urllib
import threading

inFile = open('proxy.txt', 'r')
outFile = open('available.txt', 'w')

lock = threading.Lock()

def test():
    while True:
        lock.acquire()
        line = inFile.readline().strip()
        lock.release()
        if len(line) == 0: break
        protocol, proxy = line.split('=')
        headers = {'Content-Type': 'application/x-www-form-urlencoded',
            'Cookie': ''}
        try:
            conn = httplib.HTTPConnection(proxy, timeout=3.0)
            conn.request(method='POST', url='http://e.meituan.com/m/account/login', body='login=ttttttttttttttttttttttttttttttttttttt&password=bb&remember_username=1&auto_login=1', headers=headers )
            res = conn.getresponse()
            ret_headers = str( res.getheaders() )
            html_doc = res.read().decode('utf-8')
            print html_doc.encode('gbk')
            if ret_headers.find(u'/m/account/login/') > 0:
                lock.acquire()
                print 'add proxy', proxy
                outFile.write(proxy + '\n')
                lock.release()
            else:
                print '.',
        except Exception, e:
            print e

all_thread = []
for i in range(50):
    t = threading.Thread(target=test)
    all_thread.append(t)
    t.start()
    
for t in all_thread:
    t.join()

inFile.close()
outFile.close()
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
3楼#
发布于:2017-02-09 12:48
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
4楼#
发布于:2017-02-09 12:52
network
小狐狸
小狐狸
  • UID55446
  • 注册日期2017-02-03
  • 最后登录2022-02-08
  • 发帖数75
  • 经验35枚
  • 威望0点
  • 贡献值32点
  • 好评度0点
5楼#
发布于:2017-02-09 15:16
warb:批量获取from bs4 import BeautifulSoup
import urllib2


of = open('proxy.txt' , 'w')

for page in range(1, 160):
    h...
回到原帖
这个脚本怎么使用?
network
小狐狸
小狐狸
  • UID55446
  • 注册日期2017-02-03
  • 最后登录2022-02-08
  • 发帖数75
  • 经验35枚
  • 威望0点
  • 贡献值32点
  • 好评度0点
6楼#
发布于:2017-02-09 15:16
warb:接着验证代理是否可用#encoding=gbk
import httplib
import time
import urllib
import threading

inFile = open('proxy.txt', 'r')
outFi...
回到原帖
这脚本做什么用处?
lord
非常火狐
非常火狐
  • UID6208
  • 注册日期2005-05-21
  • 最后登录2024-03-27
  • 发帖数634
  • 经验81枚
  • 威望0点
  • 贡献值12点
  • 好评度3点
  • 社区居民
  • 忠实会员
7楼#
发布于:2017-02-09 18:09
python 代码,要安装 Python运行环境
如果是Windows不想装,可以改写为 powershell 代码
心想事成,人生如梦
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
8楼#
发布于:2017-02-10 06:59
安装了python可是http://www.jb51.net/article/90783.htm这里的代码运行后无反应呀
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
9楼#
发布于:2017-02-10 18:31
找到一个https://github.com/nladuo/AutoShadowsocks但是这个模块怎么加入到里面呢。请傻瓜教程
taoww
非常火狐
非常火狐
  • UID39284
  • 注册日期2013-03-18
  • 最后登录2024-05-16
  • 发帖数634
  • 经验580枚
  • 威望0点
  • 贡献值110点
  • 好评度104点
10楼#
发布于:2017-02-10 20:45
不知底细的代理也敢用,看来你真不把自己的账号密码当回事。
taoww
非常火狐
非常火狐
  • UID39284
  • 注册日期2013-03-18
  • 最后登录2024-05-16
  • 发帖数634
  • 经验580枚
  • 威望0点
  • 贡献值110点
  • 好评度104点
11楼#
发布于:2017-02-10 20:47
warb:找到一个https://github.com/nladuo/AutoShadowsocks但是这个模块怎么加入到里面呢。请傻瓜教程回到原帖
https://www.visualstudio.com/downloads/ 下载Visual Studio,用其打开AutoShadowsocks.sln文件,进行编译
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
12楼#
发布于:2017-02-11 07:54
taoww:https://www.visualstudio.com/downloads/ 下载Visual Studio,用其打开AutoShadowsocks.sln文件,进行编译回到原帖
能说详细点吗,使用的是windows系统。谢谢提醒安全问题,只是使用免费的账号。现在提供免费的很多,用一段就不能使用了,一个个换麻烦,想找从网页上直接抓取并导入代理的方法。
warb
非常火狐
非常火狐
  • UID51578
  • 注册日期2015-10-28
  • 最后登录2019-05-04
  • 发帖数639
  • 经验666枚
  • 威望0点
  • 贡献值816点
  • 好评度27点
13楼#
发布于:2017-02-11 11:41
大家看看http://www.jb51.net/article/90783.htm这里的脚本复制后放到python里面回车后不能运行。
infinity
狐狸大王
狐狸大王
  • UID48261
  • 注册日期2014-12-18
  • 最后登录2023-03-15
  • 发帖数352
  • 经验350枚
  • 威望0点
  • 贡献值96点
  • 好评度34点
  • 社区居民
  • 忠实会员
14楼#
发布于:2017-02-14 07:54
不错,总算从你的帖子里找到了点有用的东西。看国内的一些视频需要用。反正没那些视频网站的账号,他们拿到我的cookies也没什么问题………………………………吧。
上一页
游客

返回顶部