这是html代码:
<!DOCTYPE html>
<html>
<title>Instructor's Page</title>
<body>
<h1>Instructor's Page</h1>
<div class="check1"> <div id="check2">
<span id="check3" class="check4"> <strong class="check5"><link href="http://schema.org/t"/>Instructor-1 name</strong>
</span>
</div>
<div class="check1"> <div id="check2">
<span id="check3" class="check4"> <strong class="check6">Instructor-2 name</strong>
</span>
</body>
</html>
我很陌生Jsoup
。如何Instructor's name
从给定的html页面中提取?
目前,我只知道打印标题。
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
public class crawl {
public static void main(String[] args) {
Document doc1;
try {
File input = new File("t.html");
doc1 = Jsoup.parse(input, "UTF-8");
// get page title
String title1 = doc1.title();
System.out.println("title : " + title1);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}