Python:如何在Excel中下载带有URL的图像并用图片替换URL? [英] Python: How to download images with the URLs in the excel and replace the URLs with the pictures?

查看:722
本文介绍了Python:如何在Excel中下载带有URL的图像并用图片替换URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下图所示,在 F 列中有一个Excel工作表和大约2,000个封面图像的URL。
我想要做的是下载带有URL的图片,并相应地将URL替换为图像。

As shown in the below picture,there's an excel sheet and about 2,000 URLs of cover images in the F column. What I want to do is that downloading the pictures with the URLs and replace the URL with the image correspondingly.


下载,将图片插入 F 列并自动删除URL。

Download,Insert the pictures into F column and remove the URLs automatically.

如何用Python进行补充?欢迎任何建议或代码。谢谢。

推荐答案

我希望这能回答您的问题:

I hope this answers your question:


  1. 使用Pandas库在行上编写循环;您可能会发现 https://pandas.pydata.org/ pandas-docs / version / 0.23 / generated / pandas.read_excel.html 如何在Pandas中的DataFrame中遍历行?有趣。

  2. 每次迭代都将相应的图片保存到文件夹中(也许命名为它们与您的熊猫指数);请参阅
    python从url保存图像
    了解如何

  3. 使用XlsxWriter库将它们放在各自的单元格上;请参阅
    的示例 https://xlsxwriter.readthedocs.io/example_images.html

  1. Write a loop over the rows using Pandas library; you might find https://pandas.pydata.org/pandas-docs/version/0.23/generated/pandas.read_excel.html and How to iterate over rows in a DataFrame in Pandas? interesting.
  2. Within every iteration save the corresponding picture into a folder (maybe name them with your Pandas index); Refer to python save image from url to learn how to save a picture from a URL.
  3. Use XlsxWriter library to put them on their respective cell; see an example at https://xlsxwriter.readthedocs.io/example_images.html

这篇关于Python:如何在Excel中下载带有URL的图像并用图片替换URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆