大家好,欢迎来到IT知识分享网。
爬取相关漏洞,并保存到本地文件
思路:
1.找相关的标签一步一步往下查询
2.有cookie才能查询
3.用import re
而不用from re import *
是为了防止冲突
#coding:utf-8
from requests import *
import re
from bs4 import BeautifulSoup as bs
header = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Cookie': '__jsluid_s=d4e6e0a49be7d6692bb040ab291b49e3; csrftoken=kII6j1AB3N2kGfpD9eWNR5wAw2J2PQ3R; Hm_lvt_6b15558d6e6f640af728f65c4a5bf687=1646290153; __jsl_clearance_s=1646293799.561|0|uPEc3ooLbvuRvBv%2BgEWWI6SaiE8%3D; Hm_lpvt_6b15558d6e6f640af728f65c4a5bf687=1646294268',
'Host': 'www.seebug.org',
'Referer': 'https://www.seebug.org/',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="98", "Microsoft Edge";v="98"',
'sec-ch-ua-platform': '"Windows"',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 Edg/98.0.1108.62'
}
for i in range(10):
# 变量1-10
url = 'https://www.seebug.org/vuldb/ssvid-994%d'%(30+i)
data = get(url, headers=header).content.decode('utf-8')
# print (data)
soup = bs(data,'lxml')
# print(soup)
title = soup.find_all('span',{'class':'pull-titile'})
#只要title就行
print (title,type(title))
re = print (title,type(title))
print(re)
retu = str(title)
# reg = re.compile(r'<span.+?>(.+?)</span>')
# b = re.findall(reg, str(title))
# print(b)
object = open('retule.txt', 'a+')
# output
object.write('\n' + retu )
object.close()
文件:
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/32363.html