2015-08-16 67 views
2

我使用netsniff.js這樣的:爲什麼netsniff.js將javascript錯誤輸出到輸出中?

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

當netsniff完成後,我在文本編輯器打開文件t.out,我看到了JS錯誤是這樣的:

 
TypeError: 'undefined' is not a function (evaluating '$('.bxslider').bxSlider({ 
    mode: 'fade', 
    preloadImages: 'all', 
    slideWidth: 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接收該域的有效文件?

回答

2

您可以到page.onErrorpage.onConsoleMessagephantom.onError事件,以防止(在netsniff.js page.open之前)的默認操作寄存器:

page.onError = function(){}; 
page.onConsoleMessage= function(){}; 
phantom.onError = function(){};