简体   繁体   中英

(python) I want to save scraped image in my folder. For example, it looks like 'google.png'

everyone!

I always make a scraping code in python. I have to save these images on my folder, But I have one problem about it.

If I run this code, it saves 0.png / 1.png / 2.png / 3.png..... like it.

However, I want to save (example) google.png / naver.png /.... ( scraped url).png

I do not know how I solve the problem now. Could you give me a hand, please?

enter image description here enter image description here

You're doing this..

for i, line in enumerate(r):
........
 browser.save_screenshot('img' + str(i) + '.png')

i represents the counter in a loop i suggest you look into enumerate . That's why you're getting images with the name 0.png , 1.png etc.

This may be what you're looking for:

browser.save_screenshot('img' + line + '.png')

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