<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-html</artifactId>
<version>22.9</version>
</dependency>
copied!  
                                                
                                                  compile(group: 'com.aspose', name: 'aspose-html', version: '22.9')
                                                
                                              
copied!  
<dependency org="com.aspose" name="aspose-html" rev="22.9">
 <artifact name="aspose-html" ext="jar"/>
</dependency>
copied!  
libraryDependencies += "com.aspose" % "aspose-html" % "22.9"
copied!  

HTML文件操纵Java API

main-banner

产品页面 | 文档 | 演示 | API参考 | 例子 | 博客 | 搜索 | 免费支持 | 临时许可

Java HTML API协助开发人员从Java应用程序中编写,阅读,修改,导航和转换(X)HTML文档。

Java API的Aspose.html可以用作无头浏览器,可让您从各种源到创建或打开现有的HTML文档,以执行操纵操作,例如删除和替换HTML节点,保存HTML文档,从HTML中提取CSS,从HTML中提取CSS,配置文档SANDBOX等。您可以使用各种方法来浏览HTML文档,例如,元素遍历,文档遍历,Xpath查询和CSS选择器查询以及通过JavaScript操纵HTML DOM,将HTML文件转换为图像或固定布局格式,并转换为XHTML和EPUBL和EPUBL和EPEPUB和EPEPUB和EPEPUB和EPEPUB和EPEPUB。文件到其他文件格式。

HTML处理功能

  • 完全用Java写并与JRE合作。
  • 支持32-bit64-bit OS支持。
  • 从不同来源创建或打开现有的HTML文档。
  • 能够通过API操纵(创建,编辑,删除,替换)HTML节点。
  • 提取特定HTML节点的CSS样式。
  • 配置影响HTML文档处理的文档沙盒。
  • 以各种方式通过HTML文档(元素遍历,文档遍历,XPath查询,CSS选择器查询)支持导航。
  • 通过JavaScript操纵HTML DOM。
  • 将Web文档转换为各种受支持的文件格式。
  • 从页面中提取文本。
  • 从页面搜索文字。
  • 在HTML文件中添加文本。
  • Create, edit, remove and replace HTML nodes
  • Extracting CSS styles for particular HTML node
  • Convert HTML documents into various supported image formats: JPEG, PNG, BMP, TIFF
  • Convert HTML documents to PDF format
  • 将HTML文档转换为XPS格式。

读写网络格式

** web:** html,xhtml^,mhtml ^^
其他: SVG*,MD **

将html保存为

固定布局: PDF,XPS
图像: Tiff,JPEG,PNG,BMP

阅读格式

图像: epub

支持环境

  • ** Microsoft Windows:** Windows Desktop&Server(X86,X64)
  • ** macOS:** Mac OS X
  • ** Linux:** Ubuntu,Opensuse,Centos等
  • ** Java版本:**J2SE 6.0(1.6)`,`J2SE 7.0(1.7)`,`j2se 8.0(1.8)

开始

Aspose.html Java API托管在Aspose存储库。您可以在Maven项目中直接使用Aspose.html将其用于Java API,并具有简单的配置。有关详细说明,请访问Installing Aspose.HTML for Java from Aspose存储库文档页面。

从远程位置加载html

HTMLDocument document = HTMLDocument(new Url("template.html"));
// read children nodes and get length information
if (document.getBody().getChildNodes().getLength() == 0)
    System.out.println("No ChildNodes found...");
// print Document URI to console. As per information above, it has to be https://www.w3.org/TR/html5/
System.out.println("Print Document URI = " + document.getDocumentURI());
// print domain name for remote HTML
System.out.println("Domain Name = " + document.getDomain());

How to use the 例子?

Clone or Download the ZIP and extract the contents to your local hard drive. This project uses Maven/Gradle build system and can be opened in any modern IDE like IntelliJ IDEA, Eclipse or NetBeans. For more details, visit our Documentation website.

Step one

For maven

mvn compile test

For gradle

gradle build

Execute all tests

Maven

mvn -Dtest="com.aspose.html.examples.**" test

Gradle

./gradlew test --tests "com.aspose.html.examples.*"

Execute single test

Maven

mvn -Dtest=例子_Java_AdvancedUsage_DOMMutationObserver_ObserveHowNodesAreAdded test

Gradle

./gradlew test --tests "com.aspose.html.examples.例子_Java_AdvancedUsage_DOMMutationObserver_ObserveHowNodesAreAdded"

Execute asynchronously test in Thread

Maven

mvn org.codehaus.mojo:exec-maven-plugin:3.0.0:java -Dexec.mainClass="com.aspose.html.examples.SimpleWait" -Dexec.classpathScope="test" -Dexec.cleanupDaemonThreads=false

Gradle

./gradlew SimpleWait

产品页面 | 文档 | 演示 | API参考 | 例子 | 博客 | 搜索 | 免费支持 | 临时许可

VersionRelease Date
22.92022年9月20日
22.82022年8月30日
22.72022年7月20日
21.122022年1月16日
21.62021年7月1日
21.52021年5月31日
21.42021年5月2日
21.32021年4月1日
20.122020年12月27日
20.9.12020年10月6日
20.82020年8月30日
20.62020年6月26日
19.92019年9月25日
19.82019年8月27日
19.72019年7月29日
19.62019年6月5日
19.52019年5月16日
19.42019年4月21日
19.32019年3月28日
18.11.12018年11月21日
18.112018年11月20日
18.10.22018年10月30日
18.10.12018年10月26日
18.102018年10月19日
18.82018年8月15日
18.62018年7月23日
18.5.12018年6月19日
18.52018年6月1日
17.122018年2月7日
17.11.12017年12月19日
17.112017年11月29日
17.102017年11月1日
17.92017年9月29日
17.82017年8月29日