def CNVD_update_checker_ERR(): # Cookie和user-agent相关所以需要手动修改请求头 header = { # 'Upgrade-Insecure-Requests': '1', 'Cookie': '__jsluid_s=712cd7ef2bf6548dc3307a0af3acb55b;JSESSIONID=9F5034F8F05C962FD9193EB14B2A091D;__jsl_clearance=1591151886.029|0|O7hmYtY7baM3UwXmh%2BAxXCqcwD0%3D', # 'Host': 'www.cnvd.org.cn', 'Accept-Encoding': 'gzip, deflate, br', # 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', # 'Connection': 'keep-alive', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0' } soup = Soup('https://www.cnvd.org.cn/webinfo/list?type=14', header=header) # soup.header['Upgrade-Insecure-Requests']='1' # soup.header['Cookie']='__jsluid_s=712cd7ef2bf6548dc3307a0af3acb55b; __jsl_clearance=1591065994.349|0|QA3ffs2Ye8hD9txZPdNIy3Eg5LA%3D' # soup=soup.make_soup() print(soup.req_header) print(soup.html) if check_soup(soup.html): return None table = soup.html.find('div', class_='blkContainerPblk') # print(table) tr = table.select('table tbody tr') print(tr) name = tr[0].get_text() print(name)
def parse(soup): if check_soup(soup.html): return [ failed_soup, failed_soup, failed_soup, failed_soup, failed_soup ] div = soup.html.find('div', class_='table-responsive') td = div.select('div tr td') print(td[2].get_text())
def HUAWEI_update_checker(): soup = Soup('https://www.huawei.com/cn/psirt/all-bulletins') if check_soup(soup.html): return None div = soup.html.find('div', class_='col-sm-7 col-sm-offset-1') h3 = div.select('div div div li') # print(h3) title = (h3[0].select('li a'))[0].get_text() title = re.sub('\r\n\s+', '', title) updatetime = (h3[0].select('li span'))[0].get_text() url = (h3[0].select('li a'))[0].get('href') return title, updatetime, 'https://www.huawei.com' + url
def HPE_update_checker_err(days_count): today = datetime.date.today() days = [str(today)] for i in range(1, days_count): days.append(str(today - datetime.timedelta(days=i))) lastday = today - datetime.timedelta(days=days_count) # soup=Soup(f"https://support.hpe.com/hpesc/public/km/search#t=Documents&sort=date%20descending&layout=table&numberOfResults=25&f:@kmdoctypedetails=[cv66000018]&f:@kmdoclanguagecode=[cv1871454,cv1871440]&f:@hpescuniversaldate=[{lastday.year}%2F{lastday.month}%2F{lastday.day}%4016%3A00%3A00..{today.year}%2F{today.month}%2F{today.day}%4016%3A00%3A00]&hpe=1") soup = Soup( 'https://support.hpe.com/hpesc/public/km/search#t=Documents&sort=relevancy&layout=table&numberOfResults=25&f:@kmdoctypedetails=[cv66000018]&f:@kmdoclanguagecode=[cv1871454,cv1871440]&f:@hpescuniversaldate=[2020%2F05%2F26%4016%3A00%3A00..2020%2F06%2F03%4016%3A00%3A00]&hpe=1' ) if check_soup(soup.html): return None print(soup.html)
def H3C_update_checker(): soup = Soup('http://www.h3c.com/cn/Service/Service_Notice/', encoding='utf-8') if check_soup(soup.html): return None # print(soup.html) div = soup.html.find('div', class_='big_sj blueA blueA1') # print(div) title = div.select('div a')[0].get_text() updatetime = div.select('div span')[0].get_text() updatetime = re.sub('\[|\]', '', updatetime) url = div.select('div a')[0].get('href') # print(updatetime) return title, updatetime, 'http://www.h3c.com' + url
def Intel_update_checker(): soup = Soup( 'https://www.intel.com/content/www/us/en/security-center/default.html') if check_soup(soup.html): return None else: div = soup.html.find('div', class_='table-responsive') td = div.select('div tr td') title = td[0].get_text() updatetime = td[3].get_text() title = re.sub('\\xa0', ' ', title) title = re.sub('\\n', '', title) updatetime = re.sub('\\n', '', updatetime) return title, updatetime, 'https://www.intel.com' + ( td[0].select('div a'))[0].get('href')
def CNNVD_notice(): soup = Soup('http://www.cnnvd.org.cn/web/cnnvdnotice/querylist.tag') # print(soup.header) if check_soup(soup.html): return None else: div = soup.html.find('div', class_='list_list') subdiv = div.select('div ul li') posts_address = [] posts_time = [] for sub in subdiv: sub = sub.select('li div') posts_address.append(((sub[0].select('div a'))[0]).get('href')) posts_time.append(sub[1].get_text()) # print(len(posts_time), len(posts_address)) return posts_address, posts_time
def Lenovo_update_checker(): soup = Soup('https://support.lenovo.com/us/en/product_security/home') print(soup.html) if check_soup(soup.html): return None div = soup.html.find_all('div', class_='right-area')