Coder Perfect

[closed] Command line tool for taking screenshots of websites (on Linux)

Problem

On Linux, what is a good command-line utility for taking screenshots of websites? I need to be able to take screenshots of webpages without having to deal with a human. I only discovered khtml2png, but I’m curious if there are any others that aren’t dependent on khtml (i.e. have good JavaScript support, …).

Asked by ujh

Solution #1

Perhaps a bit additional information would be helpful…

Start a firefox (or other browser) in an X session on your console or using a vncserver. You can make the window full screen by using the —height and —width arguments. A different firefox command can be used to change the URL in the initial firefox window. You can now take the screen image using one of numerous commands, such as the Imagemagick package’s “import” command, or gimp, fbgrab, or xv.

#!/bin/sh

# start a server with a specific DISPLAY
vncserver :11 -geometry 1024x768

# start firefox in this vnc session
firefox --display :11

# read URLs from a data file in a loop
count=1
while read url
do
    # send URL to the firefox session
    firefox --display :11 $url

    # take a picture after waiting a bit for the load to finish
    sleep 5
    import -window root image$count.jpg

    count=`expr $count + 1`
done < url_list.txt

# clean up when done
vncserver -kill :11

Answered by Shannon Nelson

Solution #2

CutyCapt is a lovely little utility that just uses Qt and QtWebkit.

Answered by m7n7

Solution #3

Look at PhantomJS, which appears to be a free programmable Webkit engine that runs on Linux, OSX, and Windows. I haven’t used it because we presently use Browshot (a commercial solution), but once our credits are depleted, we’ll give it a go (since it’s free and can run on our servers).

Answered by MaxiWheat

Solution #4

scrot is a command-line utility that allows you to take screenshots. See the man page and this tutorial for further information.

You should also consider scripting the browser. There are Firefox add-ons that take screenshots, such as screengrab (which can capture the entire page, not just the viewable part), and you can then script the browser to take the screenshots with greasemonkey.

Answered by Hamish Downer

Solution #5

See Webkit2png.

This is what I believe I utilized in the past.

Edit I realize I haven’t tried any of the above, however I came on this page with reviews of a variety of programs and strategies.

Answered by Luke H

Post is based on https://stackoverflow.com/questions/125951/command-line-program-to-create-website-screenshots-on-linux