- A+
# -*- coding:utf-8 -*-
import urllib
import urllib2
import re
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
page=1
file_object=open('jinghua.txt','w')
while (page<4418):
url="http://wooyun.org/bugs/page/"+str(page)
try:
request=urllib2.Request(url)
response=urllib2.urlopen(request)
#print response.read()
content = response.read().decode('utf-8')
pattern = re.compile('<td><a.*?href="(.*?)">(.*?)</a>(.*?)</td>',re.S)
items = re.findall(pattern,content)
for item in items:
haveImg=re.search('credit.png',item[2])
if haveImg:
#print item[0]+"\t",item[1]
file_object.write(item[0]+"\t"+item[1]+"\n")
except urllib2.URLError,e:
if hasattr(e,"code"):
print e.code
if hasattr(e,"reason"):
print e.reason
page=page+1
file_object.close()
View Code
- 我的微信
- 这是我的微信扫一扫
- 我的微信公众号
- 我的微信公众号扫一扫