简体   繁体   English

JSOUP。 如何使用此页面上的select提取数据?

[英]JSOUP. How to extract data with select on this page?

Hello I'm new using "jsoup" And tried to extract data from this page but for more that I combine the "id" and "class" does not show me anything. 您好,我是使用“ jsoup”的新手,并尝试从此页面提取数据,但更多的我将“ id”和“ class”组合在一起并没有显示任何内容。

enter image description here 在此处输入图片说明

The code is this: 代码是这样的:

 Document d = getHtmlDocument("http://www.mismarcadores.com/futbol/inglaterra/league-one/resultados/"); 
 System.out.println("El Status Code  es: "+getStatusConnectionCode("http://www.mismarcadores.com/futbol/inglaterra/league-one/resultados/"));

Elements ele=d.select("#fs-results");
System.out.println("Numero de entradas en la pagina mismarcadores: "+ele.size()+"\n");

With other pages if it extract your information. 与其他页面一起提取信息。

Thanks..... 谢谢.....

I believe you'll be after something like this: 我相信您会喜欢这样的事情:

Element element = d.getElementById("fs-results");

or 要么

Elements elements = d.getElementsByClass("fs-table");

The tag that contains data for this page is <div id="tournament-page-data-results">. 包含该页面数据的标签是<div id =“ tournament-page-data-results”>。 This code will get you that data. 此代码将为您获取数据。 However, the format of the data is very strange to me and I am not able to help with that. 但是,数据格式对我来说很奇怪,对此我无能为力。 Sometimes to find the data, right-click on the page in a browser, "view source code", look through the source code and identify the tag with the data. 有时要查找数据,请在浏览器中的页面上单击鼠标右键,“查看源代码”,浏览源代码并使用数据标识标签。

Document d = Jsoup.connect(url).get();
//Option 1.
Element element = d.getElementById("tournament-page-data-results");
System.out.println(element.text());
//Option 2 with select.
Elements element2 = d.select("#tournament-page-data-results");
System.out.println(element2.get(0).text());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM