0

我正在尝试接收 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 不显示?

4

1 回答 1

0

PhantomJS (versions 1 and 2) doesn't support <audio>, <video> or flash. You won't see the requests that you expect, because they are not sent.

SlimerJS which has the same API as PhantomJS uses the Gecko engine and supports <audio> and <video>.

于 2015-02-26T12:24:05.373 回答