如何启用Flash到HTMLUnit?
我正在尝试通过HTMLUnit获取HTML内容。 一切都很顺利,但无法获得那些可见的其实际位于
Flash内容
webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setActiveXNative(true); webClient.getOptions().setAppletEnabled(true); webClient.getOptions().setCssEnabled(true);
在某些地方,我发现有人说HTMLUnit不支持Flash,但这些答案看起来很旧,所以提出这个问题。 有人请帮忙。 谢谢。
我找到它的帮助 ,我已经将我的HTMLUnit版本从2.15降级到2.13,如2.15 BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW
似乎已被弃用,并且不知道这里替换了哪个function。
private static BrowserVersion firefox17WithUptoDateFlash = new BrowserVersion(BrowserVersion.FIREFOX_17.getApplicationName(), BrowserVersion.FIREFOX_17.getApplicationVersion(), BrowserVersion.FIREFOX_17.getUserAgent(), BrowserVersion.FIREFOX_17.getBrowserVersionNumeric(),new BrowserVersionFeatures[]{ BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW, BrowserVersionFeatures.STYLESHEET_HREF_EXPANDURL, BrowserVersionFeatures.STYLESHEET_HREF_STYLE_NULL }); static { PluginConfiguration plugin1 = new PluginConfiguration( "Shockwave Flash", "Shockwave Flash 11.4 r402", "NPSWF32_11_4_402_287.dll"); plugin1.getMimeTypes().add(new PluginConfiguration.MimeType( "application/x-shockwave-flash", "Adobe Flash movie", "swf")); firefox17WithUptoDateFlash.getPlugins().add(plugin1); } final WebClient webClient = new WebClient(firefox17WithUptoDateFlash);
这里新编写的浏览器实例将支持htmlunit充当支持闪存的无GUI浏览器