Created
July 25, 2019 15:05
-
-
Save jarekt/433c66722f384454bfcd2bbb757c1a7e to your computer and use it in GitHub Desktop.
python script for downloading and extracting zip files from the internet
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
#simple script for downloading github repos easily | |
import requests | |
import zipfile | |
import os | |
url = 'https://github.com/jarekt/jlib/archive/master.zip' | |
folder = 'jlib' | |
#zip conents into this ^ folder | |
r = requests.get(url) | |
if not r: | |
print('download failed, try again or download %s manually' % url) | |
exit() | |
open('temp.zip', 'wb').write(r.content) | |
zipfile.ZipFile('temp.zip').extractall() | |
os.rename(zipfile.ZipFile('temp.zip').namelist()[0], folder) | |
os.remove('temp.zip') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this script downloads a zip file from an url and extracts it into a folder