This commit is contained in:
caiwx86 2022-12-06 23:06:22 +08:00
parent f15572fc77
commit d074a3ade7

View File

@ -48,10 +48,13 @@ def download_image(image_url, dst_dir, file_name, timeout=20, proxy_type=None, p
except Exception as e:
if response:
response.close()
if repair_count < 5:
download_image(image_url,dst_dir,file_name)
repair_count += 1
print("## Fail: {} {}".format(image_url, e.args))
def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, timeout=360, proxy_type=None, proxy=None,filesName=None):
def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, timeout=20, proxy_type=None, proxy=None,filesName=None):
"""
Download image according to given urls and automatically rename them in order.
:param timeout:
@ -74,4 +77,4 @@ def download_images(image_urls, dst_dir, file_prefix="img", concurrency=50, time
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=360)
concurrent.futures.wait(future_list, timeout=180)