Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import requests # just a choice of comfort for me
  2. def download(url_address, filename):
  3. response = requests.get(url_address, stream=True)
  4. response.raise_for_status()
  5. with open(filename, "wb") as f:
  6. total_length = response.headers.get('content-length')
  7. if total_length is None:
  8. f.write(response.content)
  9. else:
  10. total_length = int(total_length)
  11. for data in response.iter_content(chunk_size = total_length / 100):
  12. f.write(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement