Download zip file using Python
https://www.zerotosingularity.com/blog/downloading-datasets-introducting-pdl/
import requests
import zipfile
import os
# download file
resp = requests.get(f"{url}{file}", allow_redirects=True, stream=True)
filename = f"{download_dir}{file}"
zfile = open(filename, 'wb')
zfile.write(resp.content)
zfile.close()
zipf = zipfile.ZipFile(filename, 'r')
zipf.extractall(download_dir)
zipf.close()
os.remove(filename)
import requests
import zipfile
import os
# download file
resp = requests.get(f"{url}{file}", allow_redirects=True, stream=True)
filename = f"{download_dir}{file}"
zfile = open(filename, 'wb')
zfile.write(resp.content)
zfile.close()
zipf = zipfile.ZipFile(filename, 'r')
zipf.extractall(download_dir)
zipf.close()
os.remove(filename)
Is this useful?
https://stackoverflow.com/questions/51665087/python-download-zip-file-from-restapi
https://stackoverflow.com/questions/51665087/python-download-zip-file-from-restapi
Comments
Post a Comment