2

我像这样使用 netsniff.js:

phantomjs --ignore-ssl-errors=true --ssl-protocol=any netsniff.js http://thermex.ru/ > t.out

当 netsniff 完成后,我在文本编辑器中打开文件 t.out,我看到了这样的 JS 错误:

TypeError: 'undefined' 不是函数(评估 '$('.bxslider').bxSlider({
    模式:'淡入淡出',
    preloadImages: '全部',
    幻灯片宽度:697
})')

http://thermex.ru/:565
http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js:2
http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js:2
http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js:2
http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js:2

在此错误之后,我看到了有效的 HAR 数据。

但我无法解析这个文件,因为他不包含有效的 JSON 数据(JS 错误 + 有效的 JSON HAR 数据 = 没有有效的 JSON 数据)。

如何从 netsniff.js 接收此域的有效文件?

4

1 回答 1

2

您可以注册到page.onError,page.onConsoleMessagephantom.onError事件以防止默认操作(page.open在 netsniff.js 之前):

page.onError = function(){};
page.onConsoleMessage= function(){};
phantom.onError = function(){};
于 2015-08-16T09:41:11.663 回答