Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download a zip file from a site (python) [closed]

There is a site with logs and each log is in zip (for space saving). How can I download it from the site?

( urllib / urllib2 )(?)

like image 298
Ofek .T. Avatar asked May 26 '13 15:05

Ofek .T.


2 Answers

You can use urllib.urlretrieve this way:

urlretrieve(your_url, your_zip_path)
like image 51
aldeb Avatar answered Nov 14 '22 21:11

aldeb


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

download a zip file to a local drive and extract all files to a destination folder using python 2.5

like image 38
asdf Avatar answered Nov 14 '22 21:11

asdf