PhantomJS onResourceReceived 没有流

PhantomJS onResourceReceived no stream

我正在尝试接收 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 我正在尝试此代码的网站如下:http://radioplayer.npo.nl/mini-player/radio4/

为什么 PhantomJS 点击按钮时 url 不显示?

PhantomJS(版本 1 和 2)不支持 <audio><video> 或 flash。您不会看到您期望的请求,因为它们没有发送。

SlimerJS 与 PhantomJS 有相同的 API 使用 Gecko 引擎并支持 <audio><video>.