What is the Java equivalent to PhantomJS? [closed]

2020-02-04 06:06发布

问题:


Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 4 years ago.

I would like to know whether there is any Java library equivalent to PhantomJS. What I want to achieve is to be able to simulate form login and submit actions from a web page and also to do page scraping as well. I know jsoup does page scraping but not page automation.

Thanks in advance!

Cheers, Alex

回答1:

There is a PhantomJS driver for Java called GhostDriver. Maybe this suits your requirements?



回答2:

  1. Selenium with Ghostdriver/PhantomJS (This is good but there is an issue with automating file uploads for a website. Other automation activites work like a charm!)

  2. Selenium with HtmlUnitDriver. HtmlUnitDriver is based on HtmlUnit which is a GUI less implementation of a browser in Java. (I have had too many exceptions with HtmlUnitDriver)

  3. Jaunt - Their website is http://jaunt-api.com/. Their short description is:

    Jaunt Beta is a new, free, Java library for web-scraping & web-automation. The library provides an ultra-light headless browser (ie, no GUI). By using Jaunt your Java programs can easily perform browser-level, document-level, and DOM-level operations. Jaunt is the ideal tool when Javascript support is not required, for tasks including: filling out and submitting forms creating web-bots or web-scraping programs. interfacing with REST APIs or web-apps (HTML, XHTML or XML). automated testing.



回答3:

Here's a similar question and answer with a list of options for you. Not all are written in Java, but there may be some suitable options for you.

headless internet browser?