Created
January 13, 2013 14:06
-
-
Save phoenixxie0/4524266 to your computer and use it in GitHub Desktop.
Python downluad and extractall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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