Last active
February 16, 2017 05:45
-
-
Save pawl/65d525f3d9defcb34870ad8a815a0b09 to your computer and use it in GitHub Desktop.
saving zip file
This file contains hidden or 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
sess = requests.session() | |
# you may have other get/post requests before you can get to the download page for the file | |
url = 'https://example.com/report.zip' | |
# this may be different for you, i just copied this from an existing request (using fiddler) | |
file_headers = { | |
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
'Accept-Language': 'en-US,en;q=0.8', | |
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)', | |
'Host': 'example.com', | |
'Accept-Encoding': 'gzip,deflate,sdch', | |
'Connection': 'Keep-Alive', | |
'Content-Type': 'application/octet-stream;charset=text/html;charset=UTF-8', | |
} | |
with open('report.zip', mode='wb') as handle: | |
report_file = sess.get(url, headers=file_headers, prefetch=False, verify=False) | |
handle.write(report_file.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment