1.网站链接:https://www.cnvd.org.cn/shareData/list
2.需要下载的页面文件:
3.该页面需要登陆,然后批量下载共享漏洞文件,我们就通过cookie来实现。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Date: 2019-08-17
Author: Bob
Description: python爬取xml文件
"""
import requests
from bs4 import BeautifulSoup
def cnvd_spider():
url = 'https://www.cnvd.org.cn/shareData/list?max=240&offset=0'
headers = {
"Cookie": "__jsluid_s=65d5e7902f04498e89b16e93fb010b3c; __jsluid_h=1ab428e655aee36ac3c9835db29b6714; JSESSIONID=91BB91B37543D365AA64895EDFCD828F; __jsl_clearance=1566003116.655|0|CYPFsKirGYBG12qtoOrS5Kq1rM0%3D",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
}
html = requests.get(url=url, headers=headers).text
soup = BeautifulSoup(html, 'lxml')
links = soup.find_all('a', attrs={'title': '下载xml'})
for link in links:
url = 'https://www.cnvd.org.cn' + link.get('href')
file_name = link.get_text()
html_data = requests.get(url=url, headers=headers)
with open(file_name, 'w') as f:
f.write(html_data.content)
if __name__ == '__main__':
cnvd_spider()
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。