Skip to content

Instantly share code, notes, and snippets.

@jarekt
Created July 25, 2019 15:05
Show Gist options
  • Save jarekt/433c66722f384454bfcd2bbb757c1a7e to your computer and use it in GitHub Desktop.
Save jarekt/433c66722f384454bfcd2bbb757c1a7e to your computer and use it in GitHub Desktop.
python script for downloading and extracting zip files from the internet
#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')
@jarekt
Copy link
Author

jarekt commented Jul 25, 2019

this script downloads a zip file from an url and extracts it into a folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment