Skip to content

Instantly share code, notes, and snippets.

@pawl
Created February 16, 2017 05:49
Show Gist options
  • Save pawl/9cac6e18fd888063141d15aac15fc253 to your computer and use it in GitHub Desktop.
Save pawl/9cac6e18fd888063141d15aac15fc253 to your computer and use it in GitHub Desktop.
import codecs
import requests
import time
# this could be different, but it works for my application, but the content-type definitely matters
fileHeaders = {
'Content-Type': 'application/octet-stream;charset=text/html;charset=UTF-8'
}
url = 'www.yourfile.com/your.zip'
with codecs.open('your.zip', mode='wb', encoding='utf-8') as handle:
zip_file = requests.get(url, headers=fileHeaders, prefetch=False)
for block in zip_file.iter_content(1024):
if block:
handle.write(block)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment