博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FreeBuf爬虫
阅读量:7110 次
发布时间:2019-06-28

本文共 2704 字,大约阅读时间需要 9 分钟。

版权声明:本文可能为博主原创文章,若标明出处可随便转载。 https://blog.csdn.net/Jailman/article/details/77673417

freebuf爬虫

#C:\Python27\python.exe#coding:utf-8import sysreload(sys)sys.setdefaultencoding("utf-8")import reimport osimport urllibimport requestsfrom multiprocessing import Poolsubject_dict = {u'漏洞':'http://www.freebuf.com/vuls', u'安全工具':'http://www.freebuf.com/sectool',                u'WEB安全':'http://www.freebuf.com/articles/web', u'系统安全':'http://www.freebuf.com/articles/system',                u'网络安全':'http://www.freebuf.com/articles/network', u'无线安全':'http://www.freebuf.com/articles/wireless',                u'终端安全':'http://www.freebuf.com/articles/terminal', u'数据安全':'http://www.freebuf.com/articles/database',                u'安全管理':'http://www.freebuf.com/articles/security-management', u'企业安全':'http://www.freebuf.com/articles/es',                u'极客':'http://www.freebuf.com/geek'}def spider(filename, url):    print "Crawling subject: %s" % filename    if os.path.isfile(filename + ".html"):        os.remove(filename + ".html")    with open(filename + ".html",'a') as f:        page = 0        error_couter = 0        while True:            page += 1            try:                html = requests.get(url + '/page/' + str(page))                code = html.status_code                if code == 404:                    error_couter += 1                    if error_couter == 1:                        print "Subject %s may only have %s pages." % (filename, str(page - 1))                    if error_couter <= 3:                        print "Retrying %s: 404 not Found!" % str(error_couter)                        continue                    else:                        print "Subject %s finished!" % filename                        print "#################################"                        break                else:                    print u"Parsing page: " + str(page)                    if page == 1:                        site = re.findall('([\s\S]*)      \n      
你可能感兴趣的文章
MySQL数据表碎片整理
查看>>
SqlParameter的size属性
查看>>
了解 GNU GPL/GNU LGPL/BSD/MIT/Apache协议
查看>>
域控升级站点后EXCHANGE2007报错问题解决
查看>>
MySQL主从复制架构
查看>>
linux /etc/init.d/functions详解
查看>>
Cocos2dx学习笔记(2) string char* int类型数据转换
查看>>
我的友情链接
查看>>
python 数据结构 tree 的插入和遍历
查看>>
Linux学习时遇到的问题5
查看>>
虚拟桌面发展的下一个里程碑,构建在CWC之上的软件定义工作空间
查看>>
Map,Map.Entry<K,V>源码分析
查看>>
看<连城诀>有感
查看>>
VTK隐函数之vtkPlane
查看>>
3、Juniper SSG550M STATUS状态灯呈红色(内存条问题)
查看>>
Docker学习——三大组件【镜像、容器、仓库】的应用(二)
查看>>
mysql原理详解及部署
查看>>
taokeeper 架设与部署
查看>>
IIS配置Sencha touch
查看>>
elasticsearch文档-analysis
查看>>