This commit is contained in:
caiwx86 2023-01-27 19:52:20 +08:00
parent 8ba3c166ad
commit 1199bd46ef

View File

@ -68,7 +68,7 @@ def download_image(image_url, dst_dir, file_name, timeout=20, proxy_type=None, p
print("## Fail: {} {}".format(image_url, e.args))
def download_images(image_urls, dst_dir,timeout=20,concurrency=5, proxy_type=None, proxy=None,files_name=None):
def download_images(image_urls, dst_dir,timeout=20, proxy_type=None, proxy=None,files_name=None):
"""
Download image according to given urls and automatically rename them in order.
:param timeout:
@ -80,6 +80,7 @@ def download_images(image_urls, dst_dir,timeout=20,concurrency=5, proxy_type=Non
:param concurrency: number of requests process simultaneously
:return: none
"""
concurrency = len(image_urls)
with concurrent.futures.ThreadPoolExecutor(max_workers=concurrency) as executor:
future_list = list()
count = 0
@ -90,7 +91,6 @@ def download_images(image_urls, dst_dir,timeout=20,concurrency=5, proxy_type=Non
future_list.append(executor.submit(
download_image, image_url, dst_dir, file_name, timeout, proxy_type, proxy))
count += 1
time.sleep(1)
concurrent.futures.wait(future_list, timeout)
def download_comic_icon():