download_image.py 376 Bytes
Newer Older
liyang's avatar
liyang committed
1 2 3 4 5 6 7 8 9 10 11 12
import requests


def download_image(url, save_path):
    response = requests.get(url, stream=True)
    if response.status_code == 200:
        with open(save_path, 'wb') as file:
            for chunk in response.iter_content(1024):
                file.write(chunk)
        # print(f"图片下载成功:{save_path}")
    else:
        print(f"图片下载失败:{url}")