Command line program to create website screenshots (on Linux) [closed]
Asked Answered
J

10

68

What is a good command line tool to create screenshots of websites on Linux? I need to automatically generate screenshots of websites without human interaction. The only tool that I found was khtml2png, but I wonder if there are others that aren't based on khtml (i.e. have good JavaScript support, ...).

Jailbird answered 24/9, 2008 at 8:3 Comment(3)
<https://mcmap.net/q/247327/-convert-web-page-to-image-closed> has some more...Newcastle
Another quick way to do it is use shutter: Install: $apt-get install shutter Run: $shutter --web=mail.ru -e'Fortitude
On-topic here: softwarerecs.stackexchange.com/questions/16422/…Ursi
T
57

A little more detail might be useful...

Start a firefox (or other browser) in an X session, either on your console or using a vncserver. You can use the --height and --width options to set the size of the window to full screen. Another firefox command can be used to set the URL being displayed in the first firefox window. Now you can grab the screen image with one of several commands, such as the "import" command from the Imagemagick package, or using gimp, or 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
Tightfisted answered 27/9, 2008 at 6:52 Comment(3)
This worked nice, except for firefox the -display :11 needed to be --display=:11 But you gave me a great starting point! Thanks for that!Risk
Very nice. Need more info though. Like with the --display option. How did you know that? Where is the documentation for doing this. Reason is, I need the program to open full screen. When I get a screenshot Firefox is not full screen but in a resizable smaller window.Avelar
This should be redirected to: No-GUI tool to take screenshots of websitesCrissman
M
40

Try nice small tool CutyCapt, which depends only on Qt and QtWebkit. ;)

Mannose answered 12/7, 2012 at 19:30 Comment(5)
Much better than the accepted answer.Worsen
CutyCapt is an awesome tool, but I used @font-face fonts, and they didn't get displayed correctly.Shop
Unfortunately it does not report result of download as exit code.Impassible
Sometime CutyCapt produces "segfaults", i cannot rely on it in a production environment!Algid
apt-get install cutycaptGazelle
J
8

Have a look at PhantomJS, which seems to be a free scritable Webkit engine that runs on Linux, OSX and Windows. I've not used it since we currently use Browshot (commercial solution), but when all our credits run out, we will seriously have a loot at it (since it's free and can run on our servers)

Jolandajolanta answered 5/6, 2013 at 13:25 Comment(2)
I just tried this (phantomjs) on my hostmonster account, a "if it works here it can work anywhere" environment. 1. download tarball 2. untar tarball 3. go to bin directory 4. cut and paste hello world example from their quick start page. 5. run hellow worldAffectionate
(cont from last post) 6. wait a few minutes (I thought that it locked up but it just took awhile for the 1st time). 6 cut and past the example below helloWorld.js 7. change example.com to site you want the screenshot. 8. run example the 5 minutes I took to do this was a lot less pain than tring to get webkit2png working, thanx MaxiWheat sorry for 2 seperate post, edit timer ran outAffectionate
F
5

scrot is a command line tool for taking screenshots. See the man page and this tutorial.

You might also want to look at scripting the browser. There are firefox add-ons that take screenshots such as screengrab (which can capture the entire page if you want, not just the visible bit) and you could then script the browser with greasemonkey to take the screenshots.

Floating answered 2/10, 2008 at 20:57 Comment(1)
Working link to scrot: freshmeat.net/projects/scrotLowry
R
3

See Webkit2png.

I think this is what I used in the past.

Edit I discover I haven't used the above, but found this page with reviews of many different programs and techniques.

Remsen answered 27/3, 2013 at 19:15 Comment(0)
B
2

I know its not a command line tool but you could easily script up something to use http://browsershots.org/ Not that useful for applications not hosted on external IPs.

A great tool none the less.

Barometrograph answered 24/9, 2008 at 8:19 Comment(1)
Actually I think I can just use the code from this project to write my own local version instead of submitting stuff through browsershots.org (because it's for a company).Jailbird
R
1

I don't know of anything custom built, I'm sure there could be something done with the gecko engine to render to a png file instead of the screen ...

Or, you could fire up firefox in full screen mode in a dedicated VNC server instance and use a screenshot grabber to take the screenshot. Fullscreen = minimal chrome, VNC server instance = no visible UI + you can choose your resolution.

Use xinit with Xvnc as the X server to do this - you'll need to read all the manpages.

Downsides are that the screenshot is always the same size, doesn't resize according to the web page ...

Roughandtumble answered 24/9, 2008 at 8:20 Comment(0)
D
1

There is the import command, but you'll need X, and a little bash script that open the browser window, then take the screenshot and close the browser.

You can find more information here, or just typing import --help in a shell ;)

Dolores answered 24/9, 2008 at 9:5 Comment(0)
S
1

http://khtml2png.sourceforge.net/

The deb file

worked on my Ubuntu after installing libkonq4 ... but you may have to cover other dependencies.

I think javascript support may be better now!

Stephan

Sammy answered 4/2, 2010 at 5:45 Comment(0)
N
1

Not for the command line but at least for usage in batch operation for a larger set of urls you may use firefox with its addon fireshot (licensed version?).

  1. Open tabs for all urls in your set (e.g. "open tabs for all bookmarks in this folder...").
  2. Then in fireshot launch "Capture all tabs"
  3. In the edit window then call "select all shots -> save all shots"

Having set the screenshot properties (size, fileformat, etc.) before you end with a nice set of shotfiles.

Steffen

Needlecraft answered 17/2, 2012 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.