phantomjs 安装使用

PhantomJS 是一个基于 WebKit 的服务器端 JavaScript API。它全面支持web而不需浏览器支持,其快速,原生支持各种Web标准: DOM 处理, CSS 选择器, JSON, Canvas, 和 SVG。 PhantomJS 可以用于 页面自动化 , 网络监测 , 网页截屏 ,以及 无界面测试 等。

mac下安装phantomjs

官网下载地址:http://phantomjs.org/download.html,官网提供的2.0.0版本在mac 10.0中会报 phantomjs killed:9 错误,解决办法下载补丁版本
https://github.com/eugene1g/phantomjs/releases/download/2.0.0-bin/phantomjs-2.0.0-macosx.zip

"""

running phantomjs on osx yosemite, download the build/fix found at:

https://github.com/eugene1g/phantomjs/releases

original issue:

https://github.com/ariya/phantomjs/issues/12928

"""

centos 下面需要下载源码手动编译,这个编译时间很长,慢慢等待。

下载地址:http://phantomjs.org/download.html

编译:http://phantomjs.org/build.html

centos下调用phantomjs的时候如果出现中文乱码或者页面看着跟网页出入比较大,可以尝试安装中文语言包:

# yum groupinstall chinese-support
# yum install bitmap-fonts bitmap-fonts-cjk   # 不装字体前中文显示不出来

注意:安装语言包后需要重启才有效。

# export LANG=zh_CN.UTF8   # 将系统字体临时设置为中文,使用ssh连接出现的错误信息已经变成中文。

phantomjs 基本使用请参考:http://www.tuicool.com/articles/beeMNj/

原文地址:https://www.cnblogs.com/weiok/p/4866473.html