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 org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
public class TestCrawTable {
public static void main(String[] args) {
String url = “网页URL”
try {
Document document = Jsoup.connect(url).get();
String result = "";
Element element = document.getElementsByTag("body").get(0);
if (element != null) {
result = element.toString().replace("<body>", "");
result = result.replace("</body>", "");
result = result.replace(""", "");
result = result.replace("\n", "");
result = result.replace("\r", "");
} else {
result = "";
}
} catch (IOException e) {
e.printStackTrace();
}
}
}