Search code examples
javapythonphantomjsjavafx-webengine

Creating an image from a webpage


I'm working on a way to detect defacement on my website. The idea is to crawl the whole website and for each page, take a screenshot or render the website as an image and compare it with the last time the page has been checked.

I'm looking for a way to convert a whole webpage (HTML, CSS, JS) into an image, like a screenshot, no matter the language is (but I would prefer Java, Python or C#)

I need it to be fast and usable on a server.

I already tried the folowing in Java:

  • CssBox, but the rendering isn't good enough (no JS)
  • Selenium Web Driver, but it's way too slow (Time to open firefox, display the page etc...) and not usable without GUI

I think a solution would be a kind of wrapper for a web engine but I didn't find anything about that (at least in Java). I've been told PhantomJS would fit for this need, is it right?

The perfect result would be to create something like that: http://www.page2images.com/home


Solution

  • Use a browser which you can control via a script or command line options like phantomjs. The documentation contains examples how to make screenshots from URLs.