日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python3-爬取cnnvd漏洞库

發(fā)布時(shí)間:2023/12/20 python 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python3-爬取cnnvd漏洞库 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

這幾天要爬cnnvd漏洞庫(kù)
網(wǎng)上找了半天發(fā)現(xiàn)各種代碼不是跑不了就不好用
于是本菜雞自己寫了一個(gè)
先上效果

我是按頁(yè)爬的
一頁(yè)目錄10條漏洞
一次爬1000頁(yè)一萬(wàn)條
一共大概128900條
表里面的內(nèi)容
不是多線程(不會(huì)),至于速度,每一萬(wàn)條在半小時(shí)左右
我每次開`6個(gè)程序爬,大概一個(gè)小時(shí)爬完的,,,

源代碼就貼在這里了(雖然想要積分)
然后爬好的xls在這里,不想花時(shí)間爬的可以直接下
python代碼和爬好的xls

# -*- coding:utf-8 -*- import sys #print (u'系統(tǒng)默認(rèn)編碼為',sys.getdefaultencoding()) default_encoding = 'utf-8' #重新設(shè)置編碼方式為uft-8 if sys.getdefaultencoding() != default_encoding:reload(sys)sys.setdefaultencoding(default_encoding) #print (u'系統(tǒng)默認(rèn)編碼為',sys.getdefaultencoding()) import requests from bs4 import BeautifulSoup import traceback import re import xlwtdef getURLDATA(url):#url = 'http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-201901-1014'header={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36','Connection': 'keep-alive',}r=requests.get(url,headers=header,timeout=30)#r.raise_for_status()拋出異常html = BeautifulSoup(r.content.decode(),'html.parser')link=html.find(class_='detail_xq w770')#漏洞信息詳情link_introduce=html.find(class_='d_ldjj')#漏洞簡(jiǎn)介link_others=html.find_all(class_='d_ldjj m_t_20')#其他#print(len(link_introduce))try:#print ("危害等級(jí):"+link.contents[3].contents[3].find('a').text.lstrip().rstrip())#危害等級(jí)list4.append(str(link.contents[3].contents[3].find('a').text.lstrip().rstrip()))except:#print("危害等級(jí):is empty")list4.append("")try:#print ("CVE編號(hào):"+link.contents[3].contents[5].find('a').text.lstrip().rstrip())#CVE編號(hào)list5.append(str(link.contents[3].contents[5].find('a').text.lstrip().rstrip()))except:#print("CVE編號(hào):is empty")list5.append("")try:#print ("漏洞類型:"+link.contents[3].contents[7].find('a').text.lstrip().rstrip())#漏洞類型list6.append(str(link.contents[3].contents[7].find('a').text.lstrip().rstrip()))except :#print("漏洞類型:is empty")list6.append("")try:#print ("發(fā)布時(shí)間:"+link.contents[3].contents[9].find('a').text.lstrip().rstrip())#發(fā)布時(shí)間list7.append(str(link.contents[3].contents[9].find('a').text.lstrip().rstrip()))except :#print("發(fā)布時(shí)間:is empty")list7.append("") try:#print ("威脅類型:"+link.contents[3].contents[11].find('a').text.lstrip().rstrip())#威脅類型list8.append(str(link.contents[3].contents[11].find('a').text.lstrip().rstrip()))except :#print("威脅類型:is empty")list8.append("")try:#print ("更新時(shí)間:"+link.contents[3].contents[13].find('a').text.lstrip().rstrip())#更新時(shí)間list9.append(str(link.contents[3].contents[13].find('a').text.lstrip().rstrip()))except :#print("更新時(shí)間:is empty")list9.append("")try:#print ("廠商:"+link.contents[3].contents[15].find('a').text.lstrip().rstrip())#廠商list10.append(str(link.contents[3].contents[15].find('a').text.lstrip().rstrip()))except:#print("廠商:is empty")list10.append("") #link_introduce=html.find(class_='d_ldjj')#漏洞簡(jiǎn)介try:link_introduce_data=BeautifulSoup(link_introduce.decode(),'html.parser').find_all(name='p')s=""for i in range(0,len(link_introduce_data)):##print (link_introduce_data[i].text.lstrip().rstrip())s=s+str(link_introduce_data[i].text.lstrip().rstrip())#print(s)list11.append(s)except :list11.append("")if(len(link_others)!=0):#link_others=html.find_all(class_='d_ldjj m_t_20')#print(len(link_others))try:#漏洞公告link_others_data1=BeautifulSoup(link_others[0].decode(),'html.parser').find_all(name='p')s=""for i in range(0,len(link_others_data1)):##print (link_others_data1[i].text.lstrip().rstrip())s=s+str(link_others_data1[i].text.lstrip().rstrip())#print(s)list12.append(s)except:list12.append("")try:#參考網(wǎng)址link_others_data2=BeautifulSoup(link_others[1].decode(),'html.parser').find_all(name='p')s=""for i in range(0,len(link_others_data2)):##print (link_others_data2[i].text.lstrip().rstrip())s=s+str(link_others_data2[i].text.lstrip().rstrip())#print(s)list13.append(s)except:list13.append("")try:#受影響實(shí)體link_others_data3=BeautifulSoup(link_others[2].decode(),'html.parser').find_all('a',attrs={'class':'a_title2'})s=""for i in range(0,len(link_others_data3)):##print (link_others_data3[i].text.lstrip().rstrip())s=s+str(link_others_data3[i].text.lstrip().rstrip())#print(s)list14.append(s)except:list14.append("")try:#補(bǔ)丁link_others_data3=BeautifulSoup(link_others[3].decode(),'html.parser').find_all('a',attrs={'class':'a_title2'})s=""for i in range(0,len(link_others_data3)):##print (link_others_data3[i].text.lstrip().rstrip())s=s+str(link_others_data3[i].text.lstrip().rstrip())#print(s)list15.append(s)except:list15.append("")else:list12.append("")list13.append("")list14.append("")list15.append("")if __name__=="__main__":global list4global list5global list6global list7global list8global list9global list10global list11global list12global list13global list14global list15list1 = []#網(wǎng)站的urllist2 = []#漏洞的名稱list3 = []#cnnvd編號(hào)list4=[]#危害等級(jí)list5=[]#CVE編號(hào)list6=[]#漏洞類型list7=[]#發(fā)布時(shí)間list8=[]#威脅類型list9=[]#更新時(shí)間list10=[]#廠商list11=[]#漏洞簡(jiǎn)介list12=[]#漏洞公告list13=[]#參考網(wǎng)址list14=[]#受影響實(shí)體list15=[]#補(bǔ)丁 start=11400last=12000#url = 'http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-201901-1014'#getURLDATA(url)f = xlwt.Workbook() # 創(chuàng)建EXCEL工作簿sheet1 = f.add_sheet(u'sheet1', cell_overwrite_ok=True) # 創(chuàng)建sheetsheet1.write(0, 0, "漏洞名稱")sheet1.write(0, 1, "網(wǎng)址")sheet1.write(0, 2, "CNNVD編號(hào)")sheet1.write(0, 3, "危害等級(jí)")sheet1.write(0, 4, "CVE編號(hào)")sheet1.write(0, 5, "漏洞類型")sheet1.write(0, 6, "發(fā)布時(shí)間")sheet1.write(0, 7, "威脅類型")sheet1.write(0, 8, "更新時(shí)間")sheet1.write(0, 9, "廠商")sheet1.write(0, 10, "漏洞簡(jiǎn)介")sheet1.write(0, 11, "漏洞公告")sheet1.write(0, 12, "參考網(wǎng)址")sheet1.write(0, 13, "受影響實(shí)體")sheet1.write(0, 14, "補(bǔ)丁")for j in range(start,last+1):# url='http://www.cnnvd.org.cn/web/vulnerability/querylist.tag?pageno=1&repairLd='url = 'http://www.cnnvd.org.cn/web/vulnerability/querylist.tag?pageno='+str(j)+'&repairLd='print ("page"+str(j))header={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36','Connection': 'keep-alive',}r=requests.get(url,headers=header,timeout=30)#r.raise_for_status()拋出異常html = BeautifulSoup(r.content.decode(),'html.parser')link=html.find_all(class_='a_title2')for i in link:##print (i.text.lstrip())try:list1.append(i.text.lstrip())##print ("http://www.cnnvd.org.cn"+i.attrs['href'])k=str(i.attrs['href'])list2.append("http://www.cnnvd.org.cn"+k)list3.append(k[28:])#print("http://www.cnnvd.org.cn"+k)getURLDATA("http://www.cnnvd.org.cn"+k)except:print("http://www.cnnvd.org.cn"+k)breakfor i in range(len(list15)):sheet1.write(i + 1, 0, list1[i])sheet1.write(i + 1, 1, list2[i])sheet1.write(i + 1, 2, list3[i])sheet1.write(i + 1, 3, list4[i])sheet1.write(i + 1, 4, list5[i])sheet1.write(i + 1, 5, list6[i])sheet1.write(i + 1, 6, list7[i])sheet1.write(i + 1, 7, list8[i])sheet1.write(i + 1, 8, list9[i])sheet1.write(i + 1, 9, list10[i])sheet1.write(i + 1, 10, list11[i])sheet1.write(i + 1, 11, list12[i])sheet1.write(i + 1, 12, list13[i])sheet1.write(i + 1, 13, list14[i])sheet1.write(i + 1, 14, list15[i])f.save(str(start)+"-"+str(last)+".xls") #保存文件

總結(jié)

以上是生活随笔為你收集整理的python3-爬取cnnvd漏洞库的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 超碰最新上传 | 极品美女无套呻吟啪啪 | 伊人激情在线 | 国产无遮挡裸体免费视频 | 亚洲AV无码成人精品一区 | 国产网址在线 | 开心激情综合 | 激情网络 | 青青草成人在线 | 成人动漫在线观看视频 | 在线视频精品一区 | 男女视频一区 | 少妇无码吹潮 | 手机av在线看| 成人免费视频网 | 久久久久久网 | 亚洲影院在线 | 成人在线视频免费 | 我们好看的2018视频在线观看 | 综合网av| 日本男男激情gay办公室 | 高清国产mv在线观看 | 抖音视频在线观看 | 成人av一区二区三区在线观看 | 久久亚洲网站 | 欧美日韩在线视频一区二区三区 | 亚洲一个色 | 国产免费观看av | 欧美黄色一级视频 | 91大神网址 | 青青草超碰在线 | 亚洲国产精品无码久久 | 免费在线观看网址入口 | av基地网 | 爽爽窝窝午夜精品一区二区 | 狠狠操在线视频 | 欧美13p| 日本啊v在线 | 视频在线观看免费大片 | 视频一区二区三 | 亚洲射情| 亚洲精品网站在线播放gif | 亚洲精品视频在线免费 | 综合久色 | 欧美黑人疯狂性受xxxxx喷水 | 在线观看日韩欧美 | av在线不卡网站 | 久久视频这里只有精品 | 另类综合视频 | 久久免费视频网站 | 欧美一二三 | 久久艹国产精品 | 美女扒开腿免费视频 | 老司机午夜免费精品视频 | 亚洲一区二区精品 | 97性视频| 国产欧美一区二区三区在线 | 少妇特黄一区二区三区 | 亚洲精品九九 | 国产一级视频在线播放 | 一区二区三区在线播放视频 | 极品美女高潮出白浆 | 亚洲青青操 | 国产精品无码一区二区桃花视频 | 高清日韩av | 毛片在线网 | 一本大道久久 | 69人妻一区二区三区 | 精品国产91乱码一区二区三区 | 国产人免费人成免费视频 | 日韩欧美成人网 | 美女扒开大腿让男人桶 | 亚洲最新中文字幕 | 亚洲午夜视频在线 | 日本一区二区在线 | 超碰蜜臀 | 欧美综合色区 | 特大黑人娇小亚洲女mp4 | 91精品国产综合久久久蜜臀图片 | 亚洲国产精品一区 | 91在线在线| www.青青操| 久久精品网址 | 日韩少妇内射免费播放18禁裸乳 | 久久久亚洲精品无码 | 91综合视频| 成人性生交大免费看 | 台湾chinesehdxxxx少妇 | av电影网站在线观看 | 丰满人妻av一区二区三区 | 天天躁日日躁狠狠躁av麻豆男男 | 91香蕉久久 | 天天干夜夜添 | 亚洲视频a| 美女下部无遮挡 | 欧美色涩在线第一页 | www成人啪啪18软件 | 精品久久无码视频 | 国产成人精品在线播放 |