[英]xpath google sheet importxml
this is the link i want to do my importxml on这是我想在上面执行 importxml 的链接
https://sg.finance.yahoo.com/quote/D05.SI https://sg.finance.yahoo.com/quote/D05.SI
<div class="dot-label Pos(r) Fz(13px) Fw(500) D(ib) Ta(c)"><span>Current</span><!-- react-text: 18 --> <!-- /react-text --><span>25.08</span></div>
i would like to use importxml to retrieve the value 25.08.我想使用 importxml 来检索值 25.08。
=IMPORTXML("https://sg.finance.yahoo.com/quote/D05.SI","//*[@class='dot-label Pos(r) Fz(13px) Fw(500) D(ib) Ta(c)']//span")
but it always return #NA, please advise the correct syntax or link and the reasons so i can have some understanding.但它总是返回#NA,请告知正确的语法或链接以及原因,以便我有所了解。
Using id
attribute selector is always safer than using class
attribute selector, because they are using class binding and it gets changed frequently.使用
id
属性选择器总是比使用class
属性选择器更安全,因为它们使用类绑定并且经常更改。 I found the closest DOM that has id
attribute, and lookup until the current price is scraped.我找到了最接近的具有
id
属性的 DOM,并查找直到当前价格被刮掉。
You should try this xpath:你应该试试这个xpath:
=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/D05.SI","//div[@id='quote-header-info']/div[last()]/div[1]"),1)
But sometimes the layout / DOM structure get changed, you might need to check and update the xpath to ensure that it correctly scrape the value that you wanted.但有时布局/DOM 结构会发生变化,您可能需要检查和更新 xpath 以确保它正确抓取您想要的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.