Skip to content

Instantly share code, notes, and snippets.

@rigibun
Created February 9, 2024 19:32
Show Gist options
  • Save rigibun/87343a209b852af938153de1706835cb to your computer and use it in GitHub Desktop.
Save rigibun/87343a209b852af938153de1706835cb to your computer and use it in GitHub Desktop.
file downloader
import requests
import time
download_count = 1
def main():
with open('download_list.txt', encoding="utf-8") as f:
urls = f.read().split()
for url in urls:
download(url)
time.sleep(1)
def download(url):
global download_count
filename = 'filename__' + str(download_count) + '.jpg'
urlData = requests.get(url).content
with open(filename, mode='wb') as f:
f.write(urlData)
print(url + " downloaded.")
download_count += 1
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment