Google表格IMPORTXML XPath-导入的内容为空 [英] Google Sheets IMPORTXML XPath - Imported Content is empty
问题描述
我正在尝试将Yahoo Finance中股票的" PEG比率"值解析为Google表格,但是看到错误.
I'm attempting to parse the 'PEG Ratio' value of a stock from Yahoo Finance into a Google Sheet, but seeing an error.
使用的网址:https://finance.yahoo.com/quote/ABBV/key-statistics?p=ABBV
使用的单元格表达式:=IMPORTXML("http://finance.yahoo.com/quote/ABBV/key-statistics?p=ABBV", "//td[@data-reactid='132']")
Cell Expression used: =IMPORTXML("http://finance.yahoo.com/quote/ABBV/key-statistics?p=ABBV", "//td[@data-reactid='132']")
错误:"#N/A "值(错误:导入的内容为空)
期望值是1.28(在发布此查询时)-来自Yahoo Finance> 统计信息"标签> PEG比率表(td具有一个我尝试在查询中过滤的属性data-reactid='132'
)
Value expected is 1.28 (at the time of posting this query) - from Yahoo Finance > Statistics tab > PEG Ratio table (td has a, attribute data-reactid='132'
that I have attempted to filter in the query)
任何人都可以帮忙吗?这是工作表的链接: Google工作表 >
Can anyone help please? Here is a link to the sheet: Google Sheet
推荐答案
问题
IMPORTXML
只能读取网站的HTML源.因此,IMPORTXML
将无法检索动态添加的网站的那些元素和组件,因此IMPORTXML
会将标签解释为空内容.
Issue
IMPORTXML
can only read the HTML source of a website. Therefore, those elements and components of a website added dynamically will not be able to be retrieved by the IMPORTXML
and thus IMPORTXML
will interpret the tag to be with empty content.
有时候,在网站的Javascript文件中,您可以找到要动态插入的数据源的URL,但这是一项繁琐的任务.
Sometimes, in the Javascript files of the website, you can find out the URL of the source of data being inserted dynamically but that is a tedious task to achieve.
要获得所需值的其他方法是使用其他网页抓取技术.
Other option to get the desired value is to use other web scraping techniques.
我希望这对您有所帮助.让我知道您是否需要其他任何东西,或者您是否不了解某些内容. :)
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
这篇关于Google表格IMPORTXML XPath-导入的内容为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!