-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1 download_data_from_official.py
29 lines (28 loc) · 1.13 KB
/
1 download_data_from_official.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
root = 'https://www.cnvd.org.cn/shareData/download/'
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Cookie': '换成自己的cookie',
'Host': 'www.cnvd.org.cn',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"'
}
for i in range(0,1500):
f=requests.get(root+str(i),headers=headers)
if f.status_code==200:
filename = 'cnvd/'+str(i)+'.xml'
with open(filename, "wb") as code:
code.write(f.content)
print(i,'存在')
else:
print(i,'不存在')