mpeg ライブ ストリームの URL を受信しようとしています。ストリームの URL は変更される可能性がありますが、サイトが変更されることはめったにないため、onResourceReceived を使用してストリームの URL をリッスンしています。
これまでのところ、何も取得していません (エラーもありません)。これが私のコードです:
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.onResourceRequested = function (req) {
console.log('requested: ' + JSON.stringify(req, undefined, 4));
};
page.onConsoleMessage = function(msg) {
system.stdout.writeLine('console: ' + msg);
};
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');
}
var radio = page.evaluate(function() {
return document.getElementById('button_playpause');
});
console.log('Radio variable: ');
console.log(radio);
console.log('Clicking button: ');
$(radio).click();
phantom.exit();
});
}
ここにあるコードを修正しました: http://phantomjs.org/network-monitoring.html このコードを試している Web サイトは次のとおりです: http://radioplayer.npo.nl/mini-player/radio4/
PhantomJS がボタンをクリックしても URL が表示されないのはなぜですか?