如何从站点下载 zip 文件 (python)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/16760992/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to download a zip file from a site (python)
提问by Ofek .T.
There is a site with logs and each log is in zip (for space saving). How can I download it from the site?
有一个带有日志的站点,每个日志都是 zip 格式的(为了节省空间)。我如何从网站上下载它?
( urllib / urllib2 )(?)
( urllib / urllib2 )(?)
采纳答案by aldeb
You can use urllib.urlretrievethis way:
你可以这样使用urllib.urlretrieve:
urlretrieve(your_url, your_zip_path)
回答by asdf
You have to consider something like:
你必须考虑这样的事情:
import urllib2
response = urllib2.urlopen('http://www.website.com/log.zip')
zipcontent= response.read()
and now you write the file to disk :)
现在您将文件写入磁盘:)
with open("log.zip", 'w') as f:
    f.write(zipcontent)
You can also check: Python and urllib
您还可以检查: Python 和 urllib
download a zip file to a local drive and extract all files to a destination folder using python 2.5

