Created
February 9, 2024 19:32
-
-
Save rigibun/87343a209b852af938153de1706835cb to your computer and use it in GitHub Desktop.
file downloader
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 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