1

I've looked for this question but I haven't come to a result at all. I know that it is possible to scrape/import web data to python, but usually the data format/set doesn't look like the visited webpage. So my question is: Is it possible at all to make a code in python to make a screenshot from a certain web page and to import it into the program?

I know that it is possible to import pictures to python, but can it also make automatically screenshots, maybe this question already exists and I haven't seen it, my apologies, in that case, I will delete this question.

Thank you very much

sma
  • 48
  • 7

1 Answers1

1

A simple way would be using selenium driver.save_screenshot() to take a screenshot, i.e.:

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://duckduckgo.com/')
ss_name = "duckduckgo.png"
driver.save_screenshot(ss_name)
driver.quit()

with open(ss_name, "rb") as f:
    for line in f:
        pass
        # do something with the screenshot binary data

duckduckgo.png

duckduckgo.png

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
  • So if I understood it correctly, this program makes screenshots from every website, saves it and when the code is expanded, it could open it in the programm. Thank you very much – sma Apr 24 '20 at 16:56
  • Yes, that's a correct assumption. If my answer helped you, please consider accepting it as the correct answer and give it 1+, thanks! – Pedro Lobito Apr 24 '20 at 16:57