PhantomJS onResource未收到流 [英] PhantomJS onResourceReceived no stream

查看:195
本文介绍了PhantomJS onResource未收到流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试接收mpeg实时流的URL. 因为流的URL可能会更改,但是网站很少更改,所以我使用onResourceReceived来侦听流的URL.

I am trying to receive the URL of a mpeg live stream. Because the url of streams might change, but a site rarely does, I am using onResourceReceived to listen for the url of the stream.

到目前为止,我还没有得到任何东西(甚至没有错误). 这是我的代码:

So far, I have not been getting anything (not even errors). Here is my code:

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/迷你播放器/radio4/

I adapted the code found here: http://phantomjs.org/network-monitoring.html The website I am trying this code on is the following: http://radioplayer.npo.nl/mini-player/radio4/

当PhantomJS单击按钮时,为什么URL不显示?

Why does the url not show up when PhantomJS clicks the button?

推荐答案

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

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.

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

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

这篇关于PhantomJS onResource未收到流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆