Search code examples
excelxpathgoogle-sheetsgoogle-shopping

How Extract data from html with xpath


I'm trying to extract product prices from Google Shopping with Google Spreadsheet:

=IMPORTXML("https://www.google.com.br/?source=pshome-c-0-3&sa=X&ved=0ahUKEwjfguD5xaHKAhXMiZAKHWjuBi8Q7j8IEA#tbm=shop&q=Samsung+Galaxy+S6&spd=0";"/div[@class='product-results']/div[@class='psli'][2]/div[@class='pslicont']/div[@class='pslmain']/div[@class='pslline'][1]/div[@class='_tyb shop__secondary']/span[@class='price']/b")

My xpath query is:

/div[@class='product-results']/div[@class='psli'][2]/div[@class='pslicont']/div[@class='pslmain']/div[@class='pslline'][1]/div[@class='_tyb shop__secondary']/span[@class='price']/b

But i don't have results.

What's Wrong?

HTML from Google Shopping Google Shopping


Solution

  • Because google in not returning HTML in actual. See the source code of the page

    • view-source:https://www.google.com.br/?source=pshome-c-0-3&sa=X&ved=0ahUKEwjfguD5xaHKAhXMiZAKHWjuBi8Q7j8IEA#tbm=shop&q=Samsung+Galaxy+S6&spd=0