[python脚本]爬blackhat官网的paper
生活随笔
收集整理的這篇文章主要介紹了
[python脚本]爬blackhat官网的paper
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
都知道blackhat上的人很牛X,自己參加不了,也只能找點人家的paper看看了。
反正沒有找到有集中打包下載的地方。都是這樣的https://www.blackhat.com/html/bh-eu-12/bh-eu-12-archives.html要想下載就要一個個點好麻煩。所以寫個蟲子,讓它自己爬。沒啥技術含量,直接在[python腳本]一個簡單的web爬蟲(1)這個上面改的·····想看paper的,自己爬吧。爬完后直接復制到迅雷下載就ok了。
eg:
python spider.py -u https://www.blackhat.com/html/bh-eu-12/bh-eu-12-#-------coding:utf-8-------
#-------author:Scr@t-------
#----filename:spider.py----
import sys import urllib2 import re import HTMLParser class myparser(HTMLParser.HTMLParser): def __init__(self): HTMLParser.HTMLParser.__init__(self) def handle_starttag(self,tag,attrs): if (tag == 'a'): URL = '' for name,value in attrs: if (name == 'href'):
for xx in ['pdf','ppt','pptx','zip','rar']:
val = value.find(xx)#所要下載的文件類型--------這個地方有問題啊,為什么只匹配pdf,后面的不匹配呢,請大神指點下 if val != -1: fp.write(value + '\n') #下面是爬sebug上的paper時,用的 # URL = value[2:] # fp.write(sys.argv[2] + URL + '\n') if sys.argv[1] == '-u': content = (urllib2.urlopen(sys.argv[2])).read()#打開網址并讀取內容 fp = open("URL.list",'w') con = myparser() con.feed(content)#把content的內容,傳給myparser分析 else: print 'Usage:%s -u url'%sys.argv[0]
----------------------------------------------在窮無非討飯,不死終會出頭。
總結
以上是生活随笔為你收集整理的[python脚本]爬blackhat官网的paper的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Reflections
- 下一篇: eclipse没有日志_「开源资讯」Jb