我正在尝试使用SlimerJS获取response.body for websocket请求。找不到提及的api页面/博客。有什么指针吗?
var page = require("webpage").create();
var url = "https://****";
page.settings.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0";
page.captureContent = [ /text\/plain/ ]; // web socket req's mime type.
var mimeTypes = {};
var timer = 0;
page.onResourceReceived = function(response) {
if(response.stage == "end") {
if(mimeTypes[response.contentType] === undefined) {
mimeTypes[response.contentType] = 1;
} else {
mimeTypes[response.contentType] = ++mimeTypes[response.contentType];
}
// ** no response body is displayed **
if(response.url.indexOf("websocket-requri.ws") !== -1){
console.log(response.id, response.url, response.contentType, response.body.substring(0,50)); // no response is displayed
}
}
};
page.open(url, function(status){
})