gpt4 book ai didi

java - 在htmlunit中过滤外部加载的javascript

转载 作者:搜寻专家 更新时间:2023-11-01 03:28:33 25 4
gpt4 key购买 nike

在使用 htmlunit 抓取网页时,我偶尔会注意到像这样的警告充斥着控制台输出。

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]

有没有办法让 htmlunit 忽略来自

的 javascript

甚至只是

同样,有没有办法让 htmlunit 只解释网页上包含特定子字符串或匹配正则表达式的 javascript?

最佳答案

您可以通过实现自己的 javascript 来删除不需要的 javascript ScriptPreProcessor .您的 ScriptPreProcessor 可以检测到您不想执行的 jsvascript,然后将其从网站中删除。

我还没有尝试过,但可能会奏效。

关于java - 在htmlunit中过滤外部加载的javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6806023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com