0
我试着用网页的代码,当我们按下keydown时,它的内容动态加载。 (如脸书)发送keydown事件在PhantomJS中不起作用
目标是获得所有净流量并将其打印到控制台。
var page = require('webpage').create(),
system = require('system'),
address;
if (system.args.length === 1) {
console.log('Usage: netlog.js <some URL>');
phantom.exit(1);
} else {
address = system.args[1];
page.onLoadFinished = function(req) {
console.log('requested: ' + JSON.stiringify(req, undefined, 4));
};
page.open(url, function() {
page.sendEvent('keypress', page.event.key.keydown);
});
page.onResourceRequested = function (req) {
console.log('requested: ' + JSON.stringify(req, undefined, 4));
};
page.onResourceReceived = function (res) {
console.log('received: ' + JSON.stringify(res, undefined, 4));
};
page.open(address, function (status) {
if (status !== 'success') {
console.log('FAIL to load the address');
}
phantom.exit();
});
}
难道我的回答帮助?你有什么问题吗? –
是的,答案帮助我感谢 – Med