请告诉我该如何解决?当页面加载了音频播放器phantomjs时,将返回以下错误:
ReferenceError: Can't find variable: Audio
试图在Internet上搜索其OS的解决方案,但未找到任何结果。操作系统:Debian 8。
我的代码(来自答案https://stackoverflow.com/a/35511597/3359390的部分):
var page = require("webpage").create();
page.open("http://95.183.11.171/ph.php", function(status) {
page.evaluate(function() {
if (!window.Audio) {
window.Audio = function() {
return {
play: function() {},
pause: function() {}
};
};
}
});
setTimeout(function() {
phantom.exit();
}, 1000);
});
最佳答案
有一种用于设置页面全局变量的解决方案:
https://github.com/ariya/phantomjs/blob/master/examples/unrandomize.js
关于javascript - PhantomJS不支持音频标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47369109/