// <!--jsoup解析工具所需依赖-->
// <dependency>
// <groupId>org.jsoup</groupId>
// <artifactId>jsoup</artifactId>
// <version>1.10.3</version>
// </dependency>
//
// <dependency>
// <groupId>junit</groupId>
// <artifactId>junit</artifactId>
// <version>4.12</version>
// <scope>test</scope>
// </dependency>
//
// <dependency>
// <groupId>commons-io</groupId>
// <artifactId>commons-io</artifactId>
// <version>2.6</version>
// </dependency>
//
// <dependency>
// <groupId>org.apache.commons</groupId>
// <artifactId>commons-lang3</artifactId>
// <version>3.7</version>
// </dependency>
package day05;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.File;
import java.io.IOException;public class jixucheshi {public static void main(String[] args) throws IOException {// Selector 选择器查找元素Document parse = Jsoup.parse(new File("C:\\Users\\LX\\Desktop\\新建文本文档.txt"), "utf-8");// 通过标签查找元素,比如:span a div/*Elements select = parse.select("li");for (Element element : select) {System.out.println(element.text());}*/
//#id:通过ID查找元素,比如:#city_bi 需要加#号
//Element element = doc.select("#city bi").first();/*Element first = parse.select("#mobileclient").first();System.out.println(first.text());*///.class:通过class名称查找元素,比如:.class_a/*Element first = parse.select(".dropdown").first();System.out.println(first.text());*///[attribute]:利用属性查找元素,比如:[abc] 需要加[] 除了class id 以外的都叫元素/* Element first = parse.select("[target]").first();System.out.println(first.text());*///[attr=value]:利用属性值来查找元素,比如:[class=s name] 完整的名字/*Element first = parse.select("[data-sudaclick=nav_app_sports_p]").first();System.out.println(first.text());*/}
}