Search code examples
pythonscreenshothtmlbackend

How can I take a screenshot/image of a website using Python?


What I want to achieve is to get a website screenshot from any website in python.

Env: Linux


Solution

  • On the Mac, there's webkit2png and on Linux+KDE, you can use khtml2png. I've tried the former and it works quite well, and heard of the latter being put to use.

    I recently came across QtWebKit which claims to be cross platform (Qt rolled WebKit into their library, I guess). But I've never tried it, so I can't tell you much more.

    The QtWebKit links shows how to access from Python. You should be able to at least use subprocess to do the same with the others.