I assume you want a screen shot of the HTML rendered, rather than the code ;) WWW::Mechanize::Firefox has a screenshot example for opening and rendering a page and saving (a screenshot of) it as a png (rather than jpeg) file.
Update: slight reword of the last sentence.
| [reply] |
| [reply] |
A slight correction - WWW::Mechanize::Firefox doesn't do a screenshot per se, it renders the page to a <canvas> HTML object and then transfers the canvas data back to Perl. But the dimensions of the resulting image are mostly determined by the size of the browser window still, so it is quite close to a screenshot still.
| [reply] [d/l] [select] |
If you are on linux, you can use this script to take a snapshot of the browser.
There is one prerequisite in that you must be on the same virtual desktop as the web browser when you run this script. You also get the whole browser, not just the html. The second script below just grabs the html using Gtk2::Webkit
| [reply] [d/l] [select] |
Depending on your requirements, you could also "print" the page to PDF, for example automating the process with X11::GUITest (or Win32::GUITest on windows). Here's an example: 945042 on automating browser interaction.
If you choose to do it via screenshots, as long as the browser window stays the same size, it's trivial to remove the browser borders from the images via something like Image::Magick
"I know what i'm doing! Look, what could possibly go wrong? All i have to pull this lever like so, and then press this button here like ArghhhhhaaAaAAAaaagraaaAAaa!!!"
| [reply] |
If you're taking screenshots, please do NOT use JPEG. JPEG is only for photographs, and a screenshot is not a photograph. The compression algorithm in JPEG will introduce ugly screen artifacts.
If you want a clean, sharp screenshot, save it in PNG or TIFF format.
| [reply] |