在Web Crapcaprap的英超联赛中遇到麻烦

发布于 2025-01-30 03:43:01 字数 1675 浏览 1 评论 0原文

我是Webscraping的完整初学者。我已经在网上遵循了几个教程,但是我似乎无法将其与首屈一指的联赛成绩一起工作。

这是我尝试从: https://www.premierleague.com/Results

我的目标是阅读所有家庭团队和客场团队,并获得他们的成绩(1-1等)。如果有人能提供帮助,我会真的对它进行融合!以下是我到目前为止尝试过的代码:

第一次尝试

String element = doc.select("div.fixtures__matches-list span.competitionLabel1").first().text();

第三次尝试

Elements elements = doc.select("div.fixtures__matches-list");

Elements matches = doc.getElementsByClass("matchList");

Element ULElement = matches.get(0);

Elements childElements = ULElement.children();


for (Element e : childElements) {
    
    String first = e.select("ul.matchList").select("li.matchFixtureContainer data-home").text();
    
    System.out.println(e.text());

}

第四次尝试

Elements test = doc.getElementsByClass("fixtures");

Element firstE = test.get(0);
System.out.println(firstE.text())

for (Element e : test) {
    System.out.println(e.text());
}

第四次尝试

Elements names = doc.select("data-home");

for (Element name : names) {
    System.out.println(name.text());
}

第五尝试,

String webUrl = "https://www.premierleague.com/results";    

Document doc = null;

try {
    doc = Jsoup.connect(webUrl).timeout(6000).get();
}
catch(IOException e) {
    e.printStackTrace();
}
    
Elements body = doc.select("div.tabbedContent");
    
for (Element e : body) {
        
String data = e.select("div.col-12 section.fixtures div.fixtures__matches-list ul.matchList").text();
        
}

我真的无法弄清楚。

I am a complete beginner to webscraping. I have followed a couple tutorials online, but I can't seem to get it to work with Premiere League results.

Here is the exact link I've tried scraping from: https://www.premierleague.com/results

My goal is to read all the home-team and away teams as well as get their results (1-1 etc.). If anyone could help I would really appreicate it! Below is code I've tried so far:

First attempt

String element = doc.select("div.fixtures__matches-list span.competitionLabel1").first().text();

Second attempt

Elements elements = doc.select("div.fixtures__matches-list");

Elements matches = doc.getElementsByClass("matchList");

Element ULElement = matches.get(0);

Elements childElements = ULElement.children();


for (Element e : childElements) {
    
    String first = e.select("ul.matchList").select("li.matchFixtureContainer data-home").text();
    
    System.out.println(e.text());

}

Third attempt

Elements test = doc.getElementsByClass("fixtures");

Element firstE = test.get(0);
System.out.println(firstE.text())

for (Element e : test) {
    System.out.println(e.text());
}

Fourth attempt

Elements names = doc.select("data-home");

for (Element name : names) {
    System.out.println(name.text());
}

Fifth attempt

String webUrl = "https://www.premierleague.com/results";    

Document doc = null;

try {
    doc = Jsoup.connect(webUrl).timeout(6000).get();
}
catch(IOException e) {
    e.printStackTrace();
}
    
Elements body = doc.select("div.tabbedContent");
    
for (Element e : body) {
        
String data = e.select("div.col-12 section.fixtures div.fixtures__matches-list ul.matchList").text();
        
}

I really can't figure it out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文