zip 下载解压

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

zip 下载解压的相关文章

ZIP文件解压

public class DZip { /// <summary> /// 压缩为ZIP文件 /// </summary> public void Zip(string directory,string fileName) { //using (var archive = ZipArchive.Create()) //{ // archive.AddAllFromDirectory(@"C:\\source"); // archive.SaveTo(@"

Linux下的压缩(zip)解压(unzip)缩命令

1.zip命令zip -r myfile.zip ./*将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件. 2.unzip命令unzip -o -d /home/sunny myfile.zip把myfile.zip文件解压到 /home/sunny/-o:不提示的情况下覆盖文件:-d:-d /home/sunny 指明将文件解压缩到/home/sunny目录下: 3.其他zip -d myfile.zip smart.txt删除压缩文件中sma

C#实现Zip压缩解压实例【转】

本文只列举一个压缩帮助类,使用的是有要添加一个dll引用ICSharpCode.SharpZipLib.dll[下载地址]. 另外说明一下的是,这个类压缩格式是ZIP的,所以文件的后缀写成 .zip. 还有,如果用这个类来解压rar格式的压缩文件时会报错,就网上说的那个"Wrong Local header signature: 0x21726152"异常.只要解压ZIP压缩格式的压缩文件就不会报错了. 下面就是Helper类的代码: using System; using Syste

zip无法解压

使用unzip解压,提示 [[email protected] html]# unzip /var/www/html/deyizhonggong.zipArchive:  /var/www/html/deyizhonggong.zip  End-of-central-directory signature not found.  Either this file is not  a zipfile, or it constitutes one disk of a multi-part archi

c++builder ZIP文件解压与压缩(ZLIB DLL调用)(转载 )

转载:http://blog.csdn.net/goodai007/article/details/7414512 头文件:ZipAndFile.h 1 //--------------------------------------------------------------------------- 2 3 #ifndef ZipAndFileH 4 #define ZipAndFileH 5 #include <Classes.hpp> 6 //-------------------

linux下zip文件解压后乱码解决方案

解决办法一,利用pyton来处理 1.vi uzip文件2.复制一下内容(Python) #!/usr/bin/env python # -*- coding: utf-8 -*- # uzip.py import os import sys import zipfile print "Processing File " + sys.argv[1] file=zipfile.ZipFile(sys.argv[1],"r"); for name in file.nam

Linux 下 zip 文件解压乱码解决方案,ubuntu16.10亲测可用

文章来源: https://www.zhihu.com/question/20523036 今天邮件中收到了一个压缩文件,解压后却是乱码,从网上也找了几个方法,目前这个方法还是比较可靠的,如下所示: 7z方案 需要安装p7zip和convmv,在Fedora下的命令是 su -c 'yum install p7zip convmv' 在ubuntu下的安装命令是 sudo apt-get install p7zip convmv 安装完之后,就可以用7za和convmv两个命令完成解压缩任务.

zip文件解压或压缩

<span style="font-size:18px;">/** * lsz */ public final class ZipUtil { /** * 解压zip文件 * @param unZipfile * @param destFile */ public static void unZip(String unZipfile, String destFile) { FileOutputStream fileOut; File file; InputStream in

linux下压缩成zip文件解压zip文件

linux  zip命令的基本用法是: zip [参数] [打包后的文件名] [打包的目录路径] linux  zip命令参数列表: -a     将文件转成ASCII模式 -F     尝试修复损坏的压缩文件     -h     显示帮助界面 -m     将文件压缩之后,删除源文件 -n 特定字符串    不压缩具有特定字尾字符串的文件 -o     将压缩文件内的所有文件的最新变动时间设为压缩时候的时间 -q     安静模式,在压缩的时候不显示指令的执行过程 -r     将指定的目录