Search code examples
xpath

XPATH WEB PAGE ALL SELECTORS RETURN NULL


I am new in stack overflow, I'am usuing a excel google sheet with Function "importfromweb" and Xpath.

I am trying to extract the telephone number from this page below trough Xpath, but the result is #ALL_SELECTORS_RETURN_NULL

Web Page: https://www.milanuncios.com/datos-contacto/?usePhoneProxy=0&from=list&includeEmail=false&id=351684334

Xpath=/html/body/div[1]/div/div[2]/div[2]/text()

Code in the Google sheet: =IMPORTFROMWEB(https://www.milanuncios.com/datos-contacto/?usePhoneProxy=0&from=list&includeEmail=false&id=351684334;/html/body/div[1]/div/div[2]/div[2]/text())

Where is the problem? With the Name I have the result, but with the telephone number is impossible!

Thanks for your help!

[The result is of XPATH: #ALL_SELECTORS_RETURN_NULL][1] [1]: https://i.sstatic.net/SJEXX.png


Solution

  • You need to activate JS rendering to get the value.

    enter image description here

    XPath :

    //div[@class="telefonos"]
    

    Formula in C5 :

    =IMPORTFROMWEB(C1;C2;B3:C3)
    

    Or retrieve it with IMPORTXML. In C8 :

    =REGEXEXTRACT(IMPORTXML(C1;"//script[contains(text(),'getTrackingPhone')]");"getTrackingPhone\((\d+)")