Home > Mobile >  Get value of next text after search string in website via xpath in google-sheets
Get value of next text after search string in website via xpath in google-sheets

Time:11-13

I'm using Google Sheet IMPORTHTML() to get the text from a website. I am trying to get the text after a certain search string via IMPORTHTML() in Google Sheet using XPath.

As an example, I would like to extract number of rooms and living space from the websites below enter image description here

CodePudding user response:

How about modifying your xpath as follows?

Modified xpath:

//p[@class='css-1ush3w6 excbu0j2' and ../..//span[text()='Zimmer']]

Result:

When this modified xpath is used for your 2 URLs, the following result is obtained.

enter image description here

In this sample, the URL and =IMPORTXML(A1, "//p[@class='css-1ush3w6 excbu0j2' and ../..//span[text()='Zimmer']]") is put to the cells "A1" and "B1", respectively.

Reference:

  • Related