Filter external loaded javascript in htmlunit

When using htmlunit to clean a webpage, I sometimes notice warnings that flood the console output.

Jul 24, 2011 5:12:59 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter warning WARNING: warning: message=[Calling eval() with anything other than a primitive string value will simply return the value. Is this what you intended?] sourceName=[http://ad.doubleclick.net/adj/N5762.morningstar.com/B5553006.25;sz=728x90;click0=http://ads.morningstar.com/RealMedia/ads/click_lx.ads/www.morningstar.com/quicktake/fund/L34/648978540/TopLeft/Morningstar/JPM_FRpt_728x90_Jul_3827448/Fund_Reports_728x90_content.html/656d5477595534723465554144664a2b?;ord=648978540?] line=[356] lineSource=[null] lineOffset=[0] 

Is there any way htmlunit can ignore javascript from

or even just

Also, is there a way for htmlunit to only interpret javascript on a webpage containing a specific substring or matching a regular expression?

+4
source share
1 answer

You may be able to remove unwanted javascript by implementing your own ScriptPreProcessor . Your ScriptPreProcessor may detect jsvascript that you do not want to execute and remove it from the website.

I have not tried it yet, but I can work.

+2
source

All Articles