Created
June 21, 2018 13:40
-
-
Save peterbe/e48ef24d59ea3d5ae37173c95cf94d72 to your computer and use it in GitHub Desktop.
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
import requests | |
import os | |
import subprocess | |
url = 'http://ftp.stage.mozaws.net/pub/firefox/candidates/61.0b15-candidates/build9/win64/en-US/buildhub.json' | |
stuff = requests.get(url).json() | |
# print(stuff['download']) | |
download_url = stuff['download']['url'] | |
r = requests.get(download_url, stream=True) | |
filename = os.path.basename(download_url) | |
with open(filename, 'wb') as f: | |
for chunk in r.iter_content(chunk_size=1024): | |
if chunk: # filter out keep-alive new chunks | |
f.write(chunk) | |
# print(r.headers) | |
print('JSON SIZE', stuff['download']['size']) | |
print('OS SIZE ', os.stat(filename).st_size) | |
print('JSON MIME', stuff['download']['mimetype']) | |
mime = subprocess.check_output(['mime', filename]).decode('utf-8').strip() | |
print('OS MIME ', mime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🎼 to my 👂 👂