How to install and use cutycapt in Centos (linux)

Source: Internet
Author: User
Tags touch centos linux mint

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.