import requestsimport osimport zipfile url="https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-modified.json.zip" headers={ "Host":"nvd.nist.gov", "Cookie":"CMSPreferredCulture=en-US; CMSCsrfCookie=BnM2YPWY/10f0fLVdGlIR9I3RVn/4Jks9oHctMmX; ASP.NET_SessionId=nbby4gh330ocgwzp354yegm0; __utma=141729133.1560305428.1576834211.1576834211.1576834211.1; __utmc=141729133; __utmz=141729133.1576834211.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=141729133.4.8.1576834247314", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"}html=requests.get(url=url,headers=headers)with open("1.zip", "wb") as code: for chunk in html.iter_content(chunk_size=1024): # 边下载边存硬盘 if chunk: code.write(chunk)root="./"zip_file_path = os.path.join(root, ‘1.zip‘)with zipfile.ZipFile(zip_file_path) as zf: zf.extractall(root)
原文地址:https://www.cnblogs.com/duanhaoxin/p/12074457.html
时间: 2024-08-30 18:02:32