缺少来自phantomjs网络监控结果的请求

时间:2014-10-28 13:23:14

标签: javascript ssl https phantomjs network-monitoring

我有一个使用AngularJS构建的Web应用程序。 我正在使用 phantomjs 网络监控来嗅探网页在页面加载时触发的所有请求。我得到以下请求列表:

 "https:.../assets/application-bf61473a35661d960c262995b314b0af.css" 
 "https:.../assets/lib/modernizr-c569e351684c78953f5f6298b4e1e485.js" 
 "https:.../assets/application-04936fc61dbebda777c3f816afa39726.js" 
 "https://www.google-analytics.com/analytics.js" 
 "https://ssl.google-analytics.com/ga.js"  
 "https:.../assets/app_install_page_header-a4b182016c1769bad626d1409b6c95f1.png"
 "https:.../assets/app_install_page_landing_text-14a162dca43a9a84b9fe0a7a77472fad.png"

问题是该列表不包含任何动态请求,例如:

我使用了waitFor方法,以便让phantomjs有时间等待延迟的请求,但它没有帮助。

我使用了此文档http://phantomjs.org/network-monitoring.html

代码:

var page = require('webpage').create();

page.onConsoleMessage = function(msg, lineNum, sourceId) {
    console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};

page.onError = function(msg, trace) {
    var msgStack = ['ERROR: ' + msg + trace];
    console.error(msgStack.join('\n'));
};

page.onResourceRequested = function(request) {
    url = request.url
    console.log(url);
};

page.onRecourseReceived = function(response) {
    console.log('received: ' + JSON.stringify(response, undefined, 4));
};

page.onLoadFinished = function() {
    page.render("on_finish.png");
};

page.open(address, function(status){

    setTimeout(function(){
        phantom.exit();
    }, 15000);
});

1 个答案:

答案 0 :(得分:3)

您似乎拥有一个本身使用https分析的http网站 最近,POODLE漏洞迫使网站所有者禁用SSLv3。自PhantomJS< v1.9.8默认使用SSLv3,由于握手失败,无法加载分析和附加脚本。因此,后续请求无法运行,因为脚本甚至没有到达浏览器。

从PhantomJS 1.9.8开始,默认协议设置为TLSv1,但可以通过将--ssl-protocol=tlsv1作为命令行选项手动为早期版本设置。有关详情,请参阅this answer

可以通过注册onResourceError事件处理程序来检查。错误消息将包含SSL handshake failed

之类的内容