Jsoup不解析特定DIv [英] Jsoup Not Parsing Particluar DIv

查看:154
本文介绍了Jsoup不解析特定DIv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从

I am unable to get the div 'live ticker' from here using Jsoup Library.

这是我的代码:

Document doc = Jsoup.connect(Link).get();

Element link = doc.select("div.data-of-match-live-experience").first();
Elements squad = doc.select("div.data-of-match-live-experience");
Elements li = squad.select("li"); // select all li from ul

Log.d("jsoup", "size: " + li.size());

推荐答案

此标记中的文本不是初始html的一部分,而是由JavaScript在页面加载后设置的.您可以通过禁用浏览器中的JavaScript进行检查. Jsoup仅获取静态html,不执行JavaScript代码.

The text in this tag in not part of initial html, but is set by JavaScript after page is loaded. You can check it by disabling JavaScript in your browser. Jsoup only gets static html, does not execute JavaScript code.

当您检查页面上建立了哪些连接时,您会发现该值是通过对此API的请求进行更新的:

When you examine what connections are made from the page you will find out that the value is updated through request to this API:

https://shapeshifter-api .onefootball.com/v1/en/match/live-experience/5/6700/718129

对此URL,解析器结果进行请求,您将获得所需的值.

Make a request to this url, parser result and you will get desired value.

这篇关于Jsoup不解析特定DIv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆