Python实现批量下载指定链接图片后改名

Python实现批量下载指定链接图片后改名


import requests

urls = ['https://carpedx.com/images/5eb4d75agw1e28yri0h5fa.jpg','https://carpedx.com/images/5eb4d75agw1e28yri0h5fb.jpg']
names = ['a.jpg','b.jpg']

for i, url in enumerate(urls):
    print(i)
    response = requests.get(url)
    with open(names[i], 'wb') as f:
        f.write(response.content)

文档信息

Search

    Table of Contents