简体   繁体   English

Python:如何在Excel中下载带有URL的图像并用图片替换URL?

[英]Python: How to download images with the URLs in the excel and replace the URLs with the pictures?

As shown in the below picture,there's an excel sheet and about 2,000 URLs of cover images in the F column. 如下图所示,在F列中有一个Excel工作表和大约2,000个封面图像的URL。 在此处输入图片说明 What I want to do is that downloading the pictures with the URLs and replace the URL with the image correspondingly. 我想要做的是下载带有URL的图片,并用图像替换URL。

Download,Insert the pictures into F column and remove the URLs automatically. 下载,将图片插入F列并自动删除URL。

How to complement it with Python ? 如何用Python补充它? Any suggestion or code is welcomed.Thanks. 欢迎任何建议或代码。谢谢。

I hope this answers your question: 我希望这回答了你的问题:

  1. Write a loop over the rows using Pandas library; 使用Pandas库在行上编写循环; 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? 您可能会发现https://pandas.pydata.org/pandas-docs/version/0.23/genic/pandas.read_excel.html以及如何在Pandas的DataFrame中遍历行? interesting. 有趣。
  2. Within every iteration save the corresponding picture into a folder (maybe name them with your Pandas index); 在每次迭代中,将相应的图片保存到一个文件夹中(也许用您的Pandas索引命名它们); Refer to python save image from url to learn how to save a picture from a URL. 请参阅python从url保存图像以了解如何从URL保存图片。
  3. Use XlsxWriter library to put them on their respective cell; 使用XlsxWriter库将它们放在各自的单元格上; see an example at https://xlsxwriter.readthedocs.io/example_images.html 请参阅https://xlsxwriter.readthedocs.io/example_images.html上的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 python 中的 url 列表中异步下载图像? - How can i asyncronously download images from a list of urls in python? python异步图像下载(多个URL) - python asyncronous images download (multiple urls) 如何从 URL 下载图像并跳过 Python 中不存在的图像? - How can I download images from URLs and skip those images that doesn't exists in Python? Python:如何用绝对URL替换文档中的所有相对URL - Python: How to replace all relative urls in a document with absolute urls 从 CSV 中的 Urls 下载图像到本地文件夹 Python 中的文件 - Download Images to Local Folder from Urls in CSV file in Python 从字典 python 中的多个 URL 下载多个图像 - Download multiple images from multiple URLS in dictionary python Python组织网址的CSV,每个网址分割线,从网址下载图像 - Python organize CSV of urls, split line per url, download images from urls 如何从 url 列表中抓取图像并将其下载到本地文件夹? - How to I scrape images from a list of urls and download it to local folder? 如何从 csv 文件中的列中的多个 url 下载图像 - how to download images from multiple urls from a column in a csv file 使用 python 从 URL 下载文件 - Download files from URLs with python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM