XPath谷歌表importxml [英] xpath google sheet importxml
问题描述
这是我要在其上执行importxml的链接
您应该尝试使用此xpath:
= INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/D05.SI","//div [@ id ='quote-header-info']/div [last()]/div [1]),1)
但是有时布局/DOM结构会发生变化,您可能需要检查并更新xpath以确保其正确地抓取了您想要的值.
this is the link i want to do my importxml on
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("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.
Using id
attribute selector is always safer than using class
attribute selector, because they are using class binding and it gets changed frequently. I found the closest DOM that has id
attribute, and lookup until the current price is scraped.
You should try this 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.
这篇关于XPath谷歌表importxml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!