Skip to content

Instantly share code, notes, and snippets.

@phoenixxie0
Created January 13, 2013 14:06
Show Gist options
  • Save phoenixxie0/4524266 to your computer and use it in GitHub Desktop.
Save phoenixxie0/4524266 to your computer and use it in GitHub Desktop.
Python downluad and extractall
import urllib2
from zipfile import *
import zipfile
# Install proxy support for urllib2
proxy_handler = urllib2.ProxyHandler({"https" : "http://127.0.0.1:8087"})
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)
# List the content of a directory (it returns an HTML page built by the proxy)
# (You will have to parse the HTML to extract the list of files and directories.)
print urllib2.urlopen("这里填写url路径,支持https").read()
# Download a file:
data = urllib2.urlopen("这里填写url路径,支持https").read()
open("master.zip","w+b").write(data)
x = zipfile.ZipFile("master.zip")
x.extractall()
x.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment