phantomjs安装使用

    xiaoxiao2026-01-21  8

    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

    抓取网页下载过程请求,类似于httpfox:

    ./bin/phantomjs examples/netsniff.js http://www.58game.com

    网页截图:

    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
    最新回复(0)