【发布时间】:2020-10-13 17:09:28
【问题描述】:
如何从 pandas 数据框中的列表中的多个 url 下载所有图像。我是python新手。
# for a single url, i can download the image:
url = ['http://pbs.twimg.com/media/EPFVkqcWkAYTDVi.jpg']
import wget
for photos in url:
wget.download(photos)
# But i have multiple url in the list.
url = ['http://pbs.twimg.com/media/EPFVkqcWkAYTDVi.jpg,http://pbs.twimg.com/media/EPFVkqcWkAYTDVi.jpg,http://pbs.twimg.com/media/EPFVkqcWkAYTDVi.jpg']
# i get error trying to download all the images
**Exception: 404: Not Found**
# I also want the download to skip any invalid url and continue.
【问题讨论】:
-
您必须将字符串拆分为列表。
url = url[0].split(',') -
单独引用每个 URL,使每个 URL 都是一个字符串。
标签: python-3.x pandas url jupyter-notebook wget