Last active
October 27, 2024 04:10
-
-
Save hantoine/c4fc70b32c2d163f604a8dc2a050d5f6 to your computer and use it in GitHub Desktop.
Download and extract a ZIP file in Python
This file contains 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
from urllib.request import urlopen | |
from io import BytesIO | |
from zipfile import ZipFile | |
def download_and_unzip(url, extract_to='.'): | |
http_response = urlopen(url) | |
zipfile = ZipFile(BytesIO(http_response.read())) | |
zipfile.extractall(path=extract_to) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dload
might be useful for others (albiet a bit buggy) https://github.com/x011/dload x011/dload#4But here is a question: how do you deal with a zip file with multiple pieces of content inside?