我有一个CSV文件。它包含产品ID,产品类别和产品图片的URL。
这是我在google colab中尝试过的代码。
import csv
import request
with open('product.csv') as csvfile:
csvrows = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in csvrows:
_product_id = row[0]
catagory = row[1]
image_url = row[2]
print(image_url)
result = requests.get(image_url, stream=True)
if result.status_code == 200:
image = result.raw.read()
open(product.csv,"wb").write(image)
我需要在Google colab中下载所有带有产品图片的信息,以供进一步操作。
Invalid syntax Image_url. Did you mean http:\\image_url?