安装phantomjs



Linux

For Ubuntu Linux (tested on a barebone install of Ubuntu 10.04 Lucid Lynx, Ubuntu 11.04 Natty Narwhal, Ubuntu 12.04 Precise Pangolin):

sudo apt-get update
sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
./build.sh

sudo apt-get install phantomjs
[sudo] password for liuken:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列【新】软件包将被安装:
  phantomjs
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 537 个软件包未被升级。
需要下载 186 kB 的软件包。
解压缩后会消耗掉 474 kB 的额外空间。
获取:1 http://cn.archive.ubuntu.com/ubuntu/ precise/universe phantomjs amd64 1.4.0+dfsg-1 [186 kB]
下载 186 kB,耗时 0秒 (640 kB/s)
Selecting previously unselected package phantomjs.
(正在读取数据库 ... 系统当前共安装有 218261 个文件和目录。)
正在解压缩 phantomjs (从 .../phantomjs_1.4.0+dfsg-1_amd64.deb) ...
正在设置 phantomjs (1.4.0+dfsg-1) ...
liuken@liuken-MS-7798:~$ phantomjs

Usage: phantomjs [options] script.[js|coffee] [script argument [script argument ...]]

Options:

--cookies-file=/path/to/cookies.txt    Sets the file name to store the persistent cookies
--config=/path/to/config               Specifies path to a JSON-formatted config file
--disk-cache=[yes|no]                  Enables disk cache (at desktop services cache storage location, default is 'no')
--ignore-ssl-errors=[yes|no]           Ignores SSL errors (i.e. expired or self-signed certificate errors)
--load-images=[yes|no]                 Loads all inlined images (default is 'yes')
--load-plugins=[yes|no]                Loads all plugins (i.e. 'Flash', 'Silverlight', ...) (default is 'no')
--local-to-remote-url-access=[yes|no]  Local content can access remote URL (default is 'no')
--max-disk-cache-size=size             Limits the size of disk cache (in KB)
--output-encoding                      Sets the encoding used for terminal output (default is 'utf8')
--proxy=address:port                   Sets the network proxy (e.g. "--proxy=192.168.1.42:8080")
--proxy-type=[http|socks5]             Sets the proxy type, either "http" (default) or "socks5"
--script-encoding                      Sets the encoding used for the starting script (default is 'utf8')
--version                              Prints out PhantomJS version

liuken@liuken-MS-7798:~$ cd phantomjs
liuken@liuken-MS-7798:~/phantomjs$ phantomjs test.js


原文地址:https://www.cnblogs.com/javawebsoa/p/3239060.html