Last active
June 8, 2018 15:27
-
-
Save todd814/c6a49f2957ae56a2269b41f8d1520caf to your computer and use it in GitHub Desktop.
dl from web for files listed in csv in python change the chunk size for bigger faster dl's
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
| import requests | |
| import csv | |
| url = "{yoururl/}" | |
| #obtain files from CSV | |
| with open('archived_files.csv') as csvfile: | |
| readCSV = csv.reader(csvfile) | |
| for row in readCSV: | |
| filename = row[0] | |
| print(filename) | |
| truepath = url + filename | |
| # create response object | |
| r = requests.get(truepath, stream=True, verify=False) | |
| # download started | |
| with open(filename, 'wb') as f: | |
| for chunk in r.iter_content(chunk_size=1): | |
| if chunk: | |
| f.write(chunk) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment