tml,'html.parser')
try:
holes_titles1 = holes_title_soup2.find_all(name='p')[0].string
holes_titles2 = holes_title_soup2.find_all(name='p')[1].string
holes_titles = holes_titles1 + holes_titles2
holes_titles = holes_titles.replace(' ','').replace('\t','').replace('\r','').replace('\n','')
except:
holes_titles = ''
holes_result_list.append(holes_titles)
#漏洞公告
holes_notice_html = holes_detainled_soup1.find('div',attrs={'class':'d_ldjj m_t_20'}) #定义 漏洞公告 块的soup
holes_notice_html = holes_notice_html.decode()
holes_notice_soup2 = BeautifulSoup(holes_notice_html,'html.parser')
try:
holes_notice1 = holes_notice_soup2.find_all(name='p')[0].string
holes_notice2 = holes_notice_soup2.find_all(name='p')[1].string
holes_notice = holes_notice1+holes_notice2
holes_notice = holes_notice.replace('\n','').replace('\r','').replace('\t','')
except:
holes_notice = ''
holes_result_list.append(holes_notice)
#参考网址
holes_reference_html = holes_detainled_soup1.find_all('div',attrs={'class':'d_ldjj m_t_20'})[1] #定义 参考网址 块的soup
holes_reference_html = holes_reference_html.decode()
holes_reference_soup2 = BeautifulSoup(holes_reference_html,'html.parser')
try:
holes_reference = holes_reference_soup2.find_all(name='p')[1].string
holes_reference = holes_reference.replace('\n','').replace('\r','').replace('\t','').replace('链接:','')
except:
holes_reference = ''
holes_result_list.append(holes_reference)
#受影响实体
holes_effect_html = holes_detainled_soup1.find_all('div',attrs={'class':'d_ldjj m_t_20'})[2] #定义 受影响实体 块的soup
holes_effect_html = holes_effect_html.decode()
holes_effect_soup2 = BeautifulSoup(holes_effect_html,'html.parser')
try:
holes_effect = holes_effect_soup2.find_all(name='p')[0].string
holes_effect = holes_effect.replace('\n','').replace('\r','').replace('\t','').replace(' ','')
except:
try:
holes_effect = holes_effect_soup2.find_all(name='a')[0].string
holes_effect = holes_effect.replace('\n','').replace('\r','').replace('\t','').replace(' ','')
except:
holes_effect = ''
holes_result_list.append(holes_effect)
#补丁
holes_patch_html = holes_detainled_soup1.find_all('div',attrs={'class':'d_ldjj m_t_20'})[3] #定义 补丁 块的soup
holes_patch_html = holes_patch_html.decode()
holes_patch_soup2 = BeautifulSoup(holes_patch_html,'html.parser')
try:
holes_patch = holes_patch_soup2.find_all(name='p')[0].string
holes_patch = holes_patch.replace('\n','').replace('\r','').replace('\t','').replace(' ','')
except:
holes_patch = ''
holes_result_list.append(holes_patch)
#漏洞信息写入excel
def holes_excel(excel):
workbook = xlsxwriter.Workbook('holes_data.xlsx')
worksheet = workbook.add_worksheet()
row = 0
col = 0
worksheet.write(row,0,'漏洞名称')
worksheet.write(row,1,'CNNVD编号')
worksheet.write(row,2,'危害等级')
worksheet.write(row,3,'CVE编号')
worksheet.write(row,4,'漏洞类型')
worksheet.write(row,5,'发布时间')
worksheet.write(row,6,'攻击途径')
worksheet.write(row,7,'更新时间')
worksheet.write(row,8,'厂商')
worksheet.write(row,9,'漏洞来源')
worksheet.write(row,10,'漏洞描述')
worksheet.write(row,11,'解决方案')
worksheet.write(row,12,'参考链接')
worksheet.write(row,13,'受影响实体')
worksheet.write(row,14,'补丁')
row = 1
for i in range(l |