我正在尝试从以下网站的表格中提取数据。即俱乐部、 field 、开始时间。 http://www.national-autograss.co.uk/february.htm
我在这里有很多使用 css 类表的例子,但这个网站没有。我尝试使用下面的代码,但它似乎没有提供任何输出。任何帮助将非常感激。
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Main {
public static void main(String[] args) {
Document doc = null;
try {
doc = Jsoup.connect("http://www.national-autograss.co.uk/february.htm").get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Elements elements = doc.select("table#table1");
String name;
for( Element element : elements )
{
name = element.text();
System.out.println(name);
}
}
}
最佳答案
id应该是唯一的,所以你应该直接使用doc.select("#table1")
等等
关于java - 使用 Jsoup 从 HTML 表中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24539948/