Install cutycapt in Centos (linux)
Install CutyCapt on Centos
Enable EPEL repository
CentOS 7
Yum install epel-release
CentOS 6 or Earlier
Rpm-Uvh http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
CentOS/RHEL 5 .*
Rpm-Uvh http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
Install cutycapt
Error reported when running cutycapt
Cutycapt: cannot connect to X server: 0
You also need to install Xvfb
Yum install Xvfb
After Xvfb is installed, cutycapt runs the command line.
Xvfb-run-server-args = "-screen 0, 1280 × 1200x24 & Prime; cutycapt-url = http://www.cnn.com -outstrap cnn.png
If multiple images are generated at the same time, run the Xvfb service on the backend.
Touch/etc/init. d/xvfb with content:
#! /Bin/bash
#
#/Etc/rc. d/init. d/xvfbd
#
# Chkconfig: 345 95 28
# Description: Starts/Stops X Virtual Framebuffer server
# Processname: Xvfb
#
./Etc/init. d/functions
["$ {NETWORKING}" = "no"] & exit 0
PROG = "Xvfb"
PROG_OPTIONS = ": 7-ac-screen 0 1024x768x24"
PROG_OUTPUT = "/tmp/Xvfb. out"
Case "$1" in
Start)
Echo-n "Starting: X Virtual Frame Buffer"
$ PROG $ PROG_OPTIONS >>$ PROG_OUTPUT 2> & 1 &
Disown-ar
/Bin/usleep 500000
Status Xvfb &>/dev/null & echo_success | echo_failure
RETVAL =$?
If [$ RETVAL-eq 0]; then
/Bin/touch/var/lock/subsys/Xvfb
/Sbin/pidof-o % PPID-x Xvfb>/var/run/Xvfb. pid
Fi
Echo
;;
Stop)
Echo-n "Shutting down: X Virtual Frame Buffer"
Killproc $ PROG
RETVAL =$?
[$ RETVAL-eq 0] & amp;/bin/rm-f/var/lock/subsys/Xvfb/var/run/Xvfb. pid
Echo
;;
Restart | reload)
$0 stop
$0 start
RETVAL =$?
;;
Status)
Status Xvfb
RETVAL =$?
;;
*)
Echo $ "Usage: $0 (start | stop | restart | reload | status )"
Exit 1
Esac
Exit $ RETVAL
Registering in system and start:
Chmod + x/etc/init. d/xvfb
Chkconfig xvfb on
Service xvfb start
Now
Export DISPLAY =: 7 (actually you shoshould add this to your etc/bashrc)
For example, convert HTML to PNG using CutyCapt on a server without X
Although CutyCapt is a command line tool, it requires the X service to run. If you try to run on a machine without the X service, you will get the following error:
Cutycapt: cannot connect to X server: 0
If you want to run CutyCapt on a server that does not contain X, you can install Xvfb on the server (lightweight "fake" X11 service ). In this way, the CutyCapt will not report an error.
To install Xvfb on Debian, Ubuntu, or Linux Mint:
$ Sudo apt-get install xvfb
To install Xvfb on Fedora, CentOS, or RHEL:
$ Sudo yum install xvfb
After Xvfb is installed, run CutyCapt like this.
$ Xvfb-run -- server-args = "-screen 0, 1280x1200x24" cutycapt -- url = http://www.cnn.com --out1_cnn.png
It runs the Xbfb service first, and then uses CutyCapt to Capture webpages. Therefore, it may take a longer time. If you want to take multiple screenshots, you may need to start Xvfb as the background daemon in advance.