雅虎财经上的 Google Sheet Web-scraping ImportXml Xpath

问题描述

我正在尝试通过网页抓取 ImportXml Xpath 将股票信息从 Yahoo Finance 获取到我的 Google 表格中。我可以让它与 %change 一起工作,但不能与价格一起工作,在那里我得到了一个我无法在页面上的任何地方重新识别的数字,任何人都可以帮助我。 我的价格的 xmlImport 如下所示:

=INDEKS(IMPORTXML("https://finance.yahoo.com/quote/CVNA?p=CVNA";"//*[@id='quote-header-info']/div[3]/div[1]/div/span[1]");1)

我的 %Change 的 xmlImport 看起来像这样

=INDEKS(IMPORTXML("https://finance.yahoo.com/quote/CVNA?p=CVNA";"//*[@id='quote-header-info']/div[3]/div[1]/div/span[2]");1)

enter image description here

解决方法

试试:

=REGEXEXTRACT(INDEX(IMPORTXML(
 "https://finance.yahoo.com/quote/CVNA?p=CVNA";
 "//*[@id='quote-header-info']");;3); "\d+.\d+|\d+")+0

enter image description here

enter image description here


更新:

=SUBSTITUTE(REGEXEXTRACT(INDEX(IMPORTXML(
 "https://finance.yahoo.com/quote/CVNA?p=CVNA"; 
 "//*[@id='quote-header-info']");;3); "\d+.\d+|\d+"); "."; ",")*1