JAVA简单解析HTML获取内容Maven 项⽬的POM⽂件引⼊
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.10</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
创建测试JAVA
import org.jsoup.Jsoup;
import des.Document;
import des.Element;
public class TestCrawTable {
public static void main(String[] args) {
String url = “⽹页URL”
try {
Document document = t(url).get();
String result = "";
Element element = ElementsByTag("body").get(0);
if (element != null) {
result = String().replace("<body>", "");
java修改html文件
result = place("</body>", "");
result = place(""", "");
result = place("\n", "");
result = place("\r", "");
} else {
result = "";
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。