From a93f68413ca4e4857cf641c29f9fd61a8f40a39d Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Wed, 15 Jan 2025 16:44:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E4=B8=8B=E8=BD=BD=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/batch_download.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tool/batch_download.py diff --git a/tool/batch_download.py b/tool/batch_download.py new file mode 100644 index 0000000..8b10394 --- /dev/null +++ b/tool/batch_download.py @@ -0,0 +1,25 @@ +# 批量下载图片 +import pandas as pd +import requests + +from ucloud import ufile + +if __name__ == '__main__': + # 读取xlsx文件 + file_path = r'D:\Echo\Downloads\Untitled.xlsx' # 将 your_file.xlsx 替换为你的文件路径 + df = pd.read_excel(file_path) + + # 循环读取 cfjaddress 列 + for address in df['cfjaddress']: + img_url = ufile.get_private_url(address) + # 下载图片并保存到本地 + response = requests.get(img_url) + + # 检查请求是否成功 + if response.status_code == 200: + # 定义保存图片的路径 + with open(f'../img/{address}', 'wb') as file: + file.write(response.content) + print(f"{address}下载成功") + else: + print(f"{address}下载失败,状态码: {response.status_code}")