Search code examples
google-sheetsweb-scrapinggoogle-sheets-formula

ImportXML Google Sheets picking price from websites


Formula gives error:

Imported content is empty.

for both URLs 1 & 2. I want Import Price of these products.

  1. https://paytmmall.com/led-night-light-wireless-tap-touch-night-lamp-light-battery-powered-wardrobe-kitchen-cabinet-closet-push-stick-on-lamps-HOMLED-NIGHT-LIGLOB317966D12FA2A-pdp

  2. https://www.amazon.in/Endless-EL-8201-Steel-Bike-Black/dp/B07MFY169J

=IMPORTXML("https://www.amazon.in/Endless-EL-8201-Steel-Bike-Black/dp/B07MFY169J","//span[@class='currencyINR']/text()")

Solution

  • for the 2nd URL, it's not doable the way you are trying. Amazon implemented anti-scraping measurements so the only way is to use their API:

    For automated access to price change or offer listing change events please refer to the MWS Subscription API: https://developer.amazonservices.com/gp/mws/api.html/277-5993977-7749460?ie=UTF8&section=subscriptions&group=subscriptions&version=latest


    =REGEXREPLACE(REGEXEXTRACT(QUERY(IMPORTXML(
     "https://paytmmall.com/led-night-light-wireless-tap-touch-night-lamp-light-battery-powered-wardrobe-kitchen-cabinet-closet-push-stick-on-lamps-HOMLED-NIGHT-LIGLOB317966D12FA2A-pdp",
     "//*"), "where Col1 contains'""price"":' limit 1"),
     "price"":(.*)""a"), ",$", "")
    

    0


    0