def download_image(url: str = '', save_path: str = '',
unverified_ctx: bool = False) -> Union[None, str]:
"""Download image and save in current directory on local machine.
:param str url: URL to image.
:param str save_path: Saving path.
:param bool unverified_ctx: Create unverified context.
:return: Image name.
:rtype: str or None
"""
if unverified_ctx:
ssl._create_default_https_context = ssl._create_unverified_context
if url is not None:
image_name = url.rsplit('/')[-1]
request.urlretrieve(url, save_path + image_name)
return image_name
return None
评论列表
文章目录