码迷,mamicode.com
首页 > 其他好文 > 详细

zip 下载解压

时间:2019-12-20 18:22:20      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:content   modified   hunk   csrf   csr   app   pfile   requests   cmd   

import requests
import os
import 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)

zip 下载解压

标签:content   modified   hunk   csrf   csr   app   pfile   requests   cmd   

原文地址:https://www.cnblogs.com/duanhaoxin/p/12074457.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!