This commit is contained in:
caiwx86 2023-01-20 21:44:10 +08:00
parent 3ff44f4226
commit 5398f1f0e4

View File

@ -80,15 +80,7 @@ def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, time
:param concurrency: number of requests process simultaneously
:return: none
"""
file_count = 0
count = 0
for image_url in image_urls:
file_name = filesName[count]
file_path = os.path.join(dst_dir, file_name)
if not os.path.exists(file_path):
file_count += 1
count += 1
concurrency = int(file_count)
concurrency = int(image_urls)
with concurrent.futures.ThreadPoolExecutor(max_workers=concurrency) as executor:
future_list = list()
count = 0
@ -96,11 +88,7 @@ def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, time
os.makedirs(dst_dir)
for image_url in image_urls:
file_name = filesName[count]
file_path = os.path.join(dst_dir, file_name)
if os.path.exists(file_path):
print("文件已存在,已跳过=",file_path)
else:
future_list.append(executor.submit(
future_list.append(executor.submit(
download_image, image_url, dst_dir, file_name, timeout, proxy_type, proxy))
count += 1
concurrent.futures.wait(future_list, timeout)