您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。