Guest User

Untitled

a guest
Mar 18th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. # Download File Common Function
  2. def download_file(url, path):
  3. local_filename = url.split('/')[-1]
  4. # NOTE the stream=True parameter
  5. r = requests.get(url, stream=True)
  6. with open(local_filename, 'wb') as f:
  7. for chunk in r.iter_content(chunk_size=1024):
  8. if chunk: # filter out keep-alive new chunks
  9. f.write(chunk)
  10. #f.flush() commented by recommendation from J.F.Sebastian
  11. shutil.move(local_filename,path+'/'+local_filename)
Add Comment
Please, Sign In to add comment