Phantomjs/Casperjs, HtmlUnit, Selenium在获取Javascript页面时特性对比
基于Phantomjs 2.0.0/Casperjs 1.1.0-beta3, Htmlunit 2.18, Selenium 2.47.1,在获取Javascript 页面时,对JavaScript engine,session/cookie支持, request url追踪, browser支持,以及访问速度,稳定性等方面进行对比如下:
框架/程序 对比项目 |
JavaScript engine |
Cookie |
request [received] url |
Browser |
访问速度,稳定性,可扩展性等 |
Base on WebKit |
支持 |
支持 |
Base on WebKit |
访问速度较快,有时程序会crash,支持各种js 框架, 缺点:支持的js有限 |
|
Rhino |
支持 |
支持 |
Firefox or Internet Explorer |
访问速度最快,比较稳定,支持各种js 框架,可以由页面类容模拟url请求. 缺点:支持的js有限 |
|
Most engine |
支持 |
不支持 |
Most Browsers |
访问速度太慢,速度也不稳定,而且带有UI,想跨平台必须使用RemoteWebDriver,优点: 支持大部分浏览器 |
|
|
|
|
|
` |
示例代码:
Phantomjs/Casperjs:-Cookie:
var fs = require('fs'); if(fs.isFile(cookieFile)) { phantom.cookies = JSON.parse(fs.read(cookieFile)); } var cookies = JSON.stringify(phantom.cookies); fs.write(cookieFile, cookies, 644);
-request [received] url:
casper.on("resource.requested", function(resource){ });
-Cookie:
webClient.getCookieManager().addCookie(cookie); webClient.getCookieManager().getCookies(); webClient.getCookieManager().clearCookies();
-request [received] url:
public static class InterceptWebConnection extends FalsifyingWebConnection{ }
-Cookie:
WebDriver driver = ...; for (Cookie ck : driver.manage().getCookies()) { javax.servlet.http.Cookie generateCookie = new javax.servlet.http.Cookie(ck.getName(), ck.getValue()); generateCookie.setMaxAge(3600); response.addCookie(generateCookie); }
相关推荐
CasperJs 是一个基于 PhantomJs 的工具,其比起 PhantomJs 可以更加方便的进行 navigation。 推荐使用PhantomJs1.9版本的 phantomjs和casperjs下载地址,casperjs下载地址,phantomjs下载地址
Learn to use PhantomJS and CasperJS to automate your interaction with the web to perform numerous tasks such as data scraping, network monitoring, page rendering, and browser testing in a programmatic...
docker run -v * pwd * /casperjs-test:/home/casperjs-test hantq/docker-casperjs casperjs /home/casperjs-test/sample.js 截屏 docker run -v * pwd * /casperjs-test:/home/casperjs-test hantq/docker-...
docker run -v `pwd`/casperjs-files:/home/casperjs-files fprieur/docker-casperjs casperjs /home/casperjs-files/sample.js 截屏 docker run -v `pwd`/casperjs-files:/home/casperjs-files fprieur/docker-...
流使用phantomjs和casperjs进行授权接收JavaScript产生的Cookie 使用Cookie的CURL GET请求要求(已通过phantomjs v1.9.8和casperjs v1.1.0-beta3测试) 幻影卡斯珀斯卷曲设置将config.example.json复制到local / ...
卡斯帕杰斯使用 PhantomJs 和 CasperJs 测试 Web 应用程序安装 NodeJ 安装 PhantomJS 安装 CasperJS
你要的,就在这里
05_phantomjs+selenium示例1.py05_phantomjs+selenium示例1.py05_phantomjs+selenium示例1.py05_phantomjs+selenium示例1.py05_phantomjs+selenium示例1.py05_phantomjs+selenium示例1.py05_phantomjs+selenium示例1...
06_phantomjs+selenium示例2.py06_phantomjs+selenium示例2.py06_phantomjs+selenium示例2.py06_phantomjs+selenium示例2.py06_phantomjs+selenium示例2.py06_phantomjs+selenium示例2.py06_phantomjs+selenium示例2...
使用casperjs开发,所需要的运行环境。解压即可使用
python获取html动态生成的数 python获取html动态生成的数
视觉调试PhantomJS / CasperJS 这个小技巧使用的是一种简单的技术:PhantomJS或CasperJS通过captureBase64('png')捕获屏幕,然后将图像发布到接收服务器,然后通过socket.io将其发送到显示的浏览器它是嵌入式图像...
启动脚本。/Users/user/phantomjs/bin/phantomjs /Users/user/phantomjs/src/run.js
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2 tar vxf phantomjs-1.9.8-linux-i686.tar.bz2 yum install openssl-devel freetype-devel fontconfig-devel cp ./bin/...
-devel Linux wget tar -xvf phantomjs-1.9.7-linux-x86_64.tar.bz2 须藤 mv phantomjs-1.9.7-linux-x86_64 /usr/local/src/phantomjs 须藤 ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/local/bin/...
安装扩展: (1)下面是我在linux上的安装... ln -sf /casperjs/bin/casperjs /usr/local/bin/casperjs //可以忽略 实际执行中php是执行 /casperjs/bin/casperjs (2)安装phantomjs,下载地址:http://phantomjs.
phantomjs 官网下载速度的实在是太慢了,几乎是挂了,于是花费5积分下载了一个
Selenium使用的phantomjs driver,功能自动化测试。可以使用Selenium直接调用driver完成功能自动化测试
利用casperjs +phantomjs实现登录抓取网页 并且截图;下载后解压后,在环境变量path中配置解压后bin目录的地址,如:E:\Program Files\casperjs\bin;E:\Program Files\phantomjs\bin
基于selenium和phantomjs爬取胜率王足球预测的信息 基于selenium和phantomjs爬取胜率王足球预测的信息