Python: How to download images with the URLs in th

2019-09-20 00:40发布

As shown in the below picture,there's an excel sheet and about 2,000 URLs of cover images in the F column. enter image description here 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.

1条回答
手持菜刀,她持情操
2楼-- · 2019-09-20 01:19

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
查看更多
登录 后发表回答