如何找出在网页上填充特定字段的AJAX网络调用URL?

huangapple go评论72阅读模式
英文:

how to find out AJAX network call url populating particular field on a webpage?

问题

在页面https://www.moneycontrol.com/india/stockpricequote/banks-private-sector/karurvysyabank/KVB 上,TTM PE数据获取速度稍慢,而在此期间数据显示为“--”。

问题在于

  • 为什么Jsoup.connect返回文档?
  • 如何找出哪个网络调用URL获取了这个特定数据?
  • 有没有办法让jsoup连接等待所有网络调用完成?
英文:

On the page https://www.moneycontrol.com/india/stockpricequote/banks-private-sector/karurvysyabank/KVB

TTM PE data gets fetched a bit slower and till that time data is shown as "--" instead.

Questions are in this case

  • why does Jsoup.connect returns document and
  • how to find out which network call url is fetching this particular data ?
  • Is there a way to make jsoup connect wait for all the network calls are complete ?

答案1

得分: 1

这个页面是一个动态页面 - 其中一部分是静态HTML,另一部分是在加载静态部分后获取的。在加载过程中,HTML部分使用"--"作为占位符,直到"真实"数据到达为止。

你无法设置延迟等待所有数据都被获取,因为jsoup不会加载它 - 它只能处理页面的静态HTML部分。

为了找到包含你特定数据的网络调用 - 大多数情况下是某个JSON文件,所以打开浏览器的开发工具(F12),转到网络选项卡,查看JSON文件。你需要打开每个文件并查找数据。在你的情况下,我认为文件是https://priceapi.moneycontrol.com/pricefeed/nse/equitycash/KVB(它被称为PE)。你需要使用其他库(比如apache httpClient)获取它,然后使用另一个库(比如jackson)解析JSON数据。

英文:

The page that you see is a dynamic page - some of it is static HTML and some of it is been fetched after the static part has been loaded. While loading it, the HTML part uses "--" just as a placeholder, until the "real" data will arrive.
You cannot set a delay to wait until all the data will be fetched, since jsoup will not load it anyway - it can handle only the static HTML part of the page.
In order to find the network call that contains your particular data - most of the odds are that it is some json file, so open the browser's dev tools (F12), go to the network tab and look at the jsons. You'll have to open each of the files and look for the data. In your case I think that the file is https://priceapi.moneycontrol.com/pricefeed/nse/equitycash/KVB (it's called PE). You'll have to fetch it with some other library, like apache httpClient, and parse the json with another library, like jackson.

huangapple
  • 本文由 发表于 2023年7月11日 12:35:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76658737.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定