Here is a little code snippet useful for downloading files from a specific URL and saving them on the filesystem:
import urllib.request
import shutil
with urllib.request.urlopen(URL_TO_FILE) as response, open(FILE_NAME, 'wb') as f:
shutil.copyfileobj(response, f)
opening the file in wb mode will create or OVERWRITE a file in binary mode
No comments:
Post a Comment
With great power comes great responsibility