简体   繁体   中英

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. 在此处输入图片说明 What I want to do is that downloading the pictures with the URLs and replace the URL with the image correspondingly.

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

How to complement it with Python ? Any suggestion or code is welcomed.Thanks.

I hope this answers your question:

  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM