Search code examples
regexgoogle-sheetsgoogle-sheets-querygoogle-sheets-formula

IMPORTXML in Google Sheets and XPath


Site address: http://www.eng.kodex.com/product_view.do?fId=2ETF68

In Google Sheets, I want to crawl prices iNAV (KRW) in the site.

I found the XPath and typed the importxml function in the spreadsheet, but it does not work.

Could not parse imported XML content

XPath: //*[@id="container"]/section/div[2]/div[1]/ul/li[2]/div/p[1]


Solution

  • =REGEXEXTRACT(QUERY(TRANSPOSE(IMPORTDATA(
     "http://www.eng.kodex.com/product_view.do?fId=2ETF68")),
     "where Col1 contains 'basp:""'"), "(\d+.*)""")
    

    or rounded:

    =ROUND(REGEXEXTRACT(QUERY(TRANSPOSE(
     IMPORTDATA("http://www.eng.kodex.com/product_view.do?fId=2ETF68")),
     "where Col1 contains 'basp:""'"), "(\d+.*)"""))
    

    0