您的位置:首页 > Web前端 > JavaScript

phantomjs安装使用

2016-05-19 10:54 435 查看
phantomjs安装

phantomjs 是一款基于webkit的无界面浏览器,提供多种js api;可以方便的进行扩展:
yum --skip-broken install fontconfig freetype libfreetype.so.6 libfontconfig.so.1
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 
tar jxvf phantomjs-1.9.7-linux-x86_64.tar.bz2
mv phantomjs-1.9.7-linux-x86_64 phantomjs
cd phantomjs


测试网页加载渲染速度:
./bin/phantomjs examples/loadspeed.js http://www.58game.com[/code] 
抓取网页下载过程请求,类似于httpfox:
./bin/phantomjs examples/netsniff.js http://www.58game.com[/code] 
网页截图:
var page = require('webpage').create();
page.open('http://www.58game.com', function() {
page.render('example.png');
phantom.exit();
});


保存为t.js,执行

先给phantomjs执行权限 chmod u+x phantomjs
./bin/phantomjs /root/t.js
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: