-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyth.py
More file actions
28 lines (20 loc) · 877 Bytes
/
pyth.py
File metadata and controls
28 lines (20 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import urllib.request
import argparse
import concurrent.futures
def download_image(url):
filename = url.split("/")[-1]
try:
urllib.request.urlretrieve(url, filename)
print(f"Загружено изображение {filename}")
except Exception as e:
print(f"Ошибка при загрузке изображения {filename}: {e}")
def main():
parser = argparse.ArgumentParser(description="Загрузка изображений из списка URL-адресов")
parser.add_argument("urls", nargs="+", help="URL-адреса изображений")
args = parser.parse_args()
urls = args.urls
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.map(download_image, urls)
print("Загрузка завершена")
if __name__ == "__main__":
main()