相当于 PhantomJS 的 Java 是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19759421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 19:59:12  来源:igfitidea点击:

What is the Java equivalent to PhantomJS?

javaselenium-webdriverweb-scrapingautomated-tests

提问by alextc

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.

我想知道是否有任何等效于 PhantomJS 的 Java 库。我想要实现的是能够模拟表单登录并从网页提交操作以及进行页面抓取。我知道 jsoup 会抓取页面,但不会进行页面自动化。

Thanks in advance!

提前致谢!

Cheers, Alex

干杯,亚历克斯

回答by SteveEdson

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.

这是一个类似的问题和答案,为您提供了一个选项列表。并非全部都是用 Java 编写的,但可能有一些适合您的选项。

headless internet browser?

无头互联网浏览器?

回答by Benny Neugebauer

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

有一个用于 Java 的 PhantomJS 驱动程序,称为GhostDriver。也许这符合您的要求?

回答by LittlePanda

  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.

  1. 带有 Ghostdriver/PhantomJS 的 Selenium(这很好,但在为网站自动上传文件时存在问题。其他自动化活动就像一个魅力!)

  2. 带有 HtmlUnitDriver 的硒。HtmlUnitDriver 基于 HtmlUnit,HtmlUnit 是 Java 中浏览器的无 GUI 实现。(我有太多的 HtmlUnitDriver 异常)

  3. Jaunt - 他们的网站是http://jaunt-api.com/。他们的简短描述是:

    Jaunt Beta 是一个新的免费 Java 库,用于网络抓取和网络自动化。该库提供了一个超轻的无头浏览器(即没有 GUI)。通过使用 Jaunt,您的 Java 程序可以轻松地执行浏览器级、文档级和 DOM 级操作。当不需要 Javascript 支持时,Jaunt 是理想的工具,其任务包括:填写和提交表单,创建网络机器人或网络抓取程序。与 REST API 或网络应用程序(HTML、XHTML 或 XML)交互。自动化测试。