Headless browser with full javascript support for java

半世苍凉 提交于 2019-11-26 18:17:56

问题


I have been using HtmlUnit (the developers did a great job) as an headless browser for some of my previous applications but the javascript support isn't working for some website that my next application will be accessing.

  1. I heard about QtWebKit binding for Python but my application will be in Java or is there a Java binding for WebKit or QtWebKit?

  2. Does anyone know a good headless browser for Java with full javascript support?


回答1:


Nathan Ridley's answer to another similar question is the most complete one I've found so far.

Anyway, if everything fails, you could use a Python or JS alternative, expose its funcionality as a webservice inside your server, and then your Java application could use the headless browser's funcionality through the webservice. It would be a pain to set up, but it may be a viable alternative if nothing else works as desired.

Also, there are some "non-headless" browser wrappers for Java; maybe it would be possible to build a testing solution around those, depending on the requirements.




回答2:


Take a look at phantom.js. Based on webkit it offers a complete headless browser.




回答3:


Rhino + env.js is a full java solution, I've used it, it's not super fast but seems reasonably stable and should give you correct js support.




回答4:


Perhaps https://github.com/machinepublishers/jbrowserdriver -- it's headless and written only in Java.

(disclosure: I'm the project owner)




回答5:


Replying on an old thread, hoping it might be useful for some.

1) You can use QTJambi's QWebView. It was reasonably fast.

2) JBrowserDriver is another option.

Personally I found QT engine a bit faster.



来源:https://stackoverflow.com/questions/11634747/headless-browser-with-full-javascript-support-for-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!