Linux:cutycapt html转jpg、png、pdf

时间:2022-11-11 21:06:24

网页转图片、pdf

链接:cutycapt主页


之前在windows下用cutycapt,要不是字体有问题,要不就是不能出图,要不就是清晰度不够。

据说Linux下的cutycapt比较好用,但是centos比较纯净,安装起来很麻烦。我就装的是Ubuntu。


环境Ubuntu 16.0.4 LTS 64位

安装

sudo apt-get install cutycapt

sudo apt-get install xvfb

使用

cutycapt --url=https://www.baidu.com --out=baidu.html --delay=5000 --zoom-factor=3

此外,还有各种参数。

注意:有条件的情况下,安装东西的时候最好能翻个墙。不然真的太慢了!!!

Usage

Open a command prompt and ask for help:

 % CutyCapt --help
 -----------------------------------------------------------------------------
 Usage: CutyCapt --url=http://www.example.org/ --out=localfile.png            
 -----------------------------------------------------------------------------
  --help                         Print this help page and exit                
  --url=<url>                    The URL to capture (http:...|file:...|...)   
  --out=<path>                   The target file (.png|pdf|ps|svg|jpeg|...)   
  --out-format=<f>               Like extension in --out, overrides heuristic 
  --min-width=<int>              Minimal width for the image (default: 800)   
  --min-height=<int>             Minimal height for the image (default: 600)  
  --max-wait=<ms>                Don't wait more than (default: 90000, inf: 0)
  --delay=<ms>                   After successful load, wait (default: 0)     
  --user-style-path=<path>       Location of user style sheet file, if any    
  --user-style-string=<css>      User style rules specified as text           
  --header=<name>:<value>        request header; repeatable; some can't be set
  --method=<get|post|put>        Specifies the request method (default: get)  
  --body-string=<string>         Unencoded request body (default: none)       
  --body-base64=<base64>         Base64-encoded request body (default: none)  
  --app-name=<name>              appName used in User-Agent; default is none  
  --app-version=<version>        appVers used in User-Agent; default is none  
  --user-agent=<string>          Override the User-Agent header Qt would set  
  --javascript=<on|off>          JavaScript execution (default: on)           
  --java=<on|off>                Java execution (default: unknown)            
  --plugins=<on|off>             Plugin execution (default: unknown)          
  --private-browsing=<on|off>    Private browsing (default: unknown)          
  --auto-load-images=<on|off>    Automatic image loading (default: on)        
  --js-can-open-windows=<on|off> Script can open windows? (default: unknown)  
  --js-can-access-clipboard=<on|off> Script clipboard privs (default: unknown)
  --print-backgrounds=<on|off>   Backgrounds in PDF/PS output (default: off)  
  --zoom-factor=<float>          Page zoom factor (default: no zooming)       
  --zoom-text-only=<on|off>      Whether to zoom only the text (default: off) 
  --http-proxy=<url>             Address for HTTP proxy server (default: none)
 -----------------------------------------------------------------------------
  <f> is svg,ps,pdf,itext,html,rtree,png,jpeg,mng,tiff,gif,bmp,ppm,xbm,xpm    
 -----------------------------------------------------------------------------
 http://cutycapt.sf.net - (c) 2003-2013 Bjoern Hoehrmann - bjoern@hoehrmann.de


中文乱码(我还没遇到)

把windows字体放到 /usr/share/fonts,执行fc-cache


安装报错

Package has no installation candidate问题,如:

# apt-get install <packagename>
Reading package lists... Done
Building dependency tree... Done
Package aptitude is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package <packagename> has no installation candidate


解决方法

# apt-get update
# apt-get upgrade
# apt-get install <packagename>

(升级后安装)


查看本地IP:ifconfig -a

--

后记

我是真的没有用过Linux,从命令行,到Vim,每一个都要命。

今天去网上下了个Ubuntu 16 64位,装在了虚拟机上,准备学一把了。