无法从动态网页使用 importXML 获取数据? [英] Can't get the data using importXML from Dynamic Web Page?

查看:22
本文介绍了无法从动态网页使用 importXML 获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网站是:https://www.futbin.com/18/播放器/2600/Ayhan/

我检查元素并获得 XPath,即://*[@id="ps-lowest-1"]

I inspect the element and get the XPath which is: //*[@id="ps-lowest-1"]

然后我使用:

=IMPORTXML("https://www.futbin.com/18/player/2600/Ayhan/","///*[@id='ps-lowest-1']")

获取应该是2000

但它只在工作表上显示:-.没有错误只是没有显示我想要的数据.有没有办法获得我需要的数据?

But instead it only shows: - on the sheet. No errors just doesn't show the data that I want it to. Is there anyway to get the data that I need?

谢谢

推荐答案

表格命令 importXML 仅读取页面的 HTML 源代码,而不对其执行任何 JavaScript.正如您在浏览器中使用查看源代码"所看到的那样,源代码在该范围内确实有-":

The Sheets command importXML reads only the HTML source of the page without executing any JavaScript on it. As you can see yourself by using "view source" in the browser, the source indeed has "-" in that span:

 <span class="price_big_right">
     <span id="ps-lowest-1">-</span>
 </span>

实际数字由某个 JavaScript 文件加载,然后将它们插入到该跨度中.importXML 和其他 Sheets 函数都不能检索动态插入的数据.

The actual numbers are loaded by some JavaScript file which then inserts them in that span. Neither importXML nor other Sheets functions can retrieve dynamically inserted data.

有时,在检查 JS 文件后,可以发现数据源的 URL 并尝试导入;但对于每个特定站点来说,这是一项繁琐的逆向工程练习.

Sometimes, after inspecting the JS files, one can uncover the URL of source of data and try to import that; but this is a tedious reverse engineering exercise for each particular site.

这篇关于无法从动态网页使用 importXML 获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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