Google Sheets IMPORTXML for Price

时间:2019-04-16 23:47:51

标签: google-sheets scrape price

I am trying to create a price scrape sheet in google sheets using the IMPORTXMLfunction. I'm having trouble identifying the path for which the price on the product page.

I've tried copying the xPath using the inspect element in Chrome but it's copying the following: //*[@id="ajaxPrice"]/span[2]

I'm sure this is not the path.

Can someone please help?

Product page: https://homedepot.com/p/206651614

2 个答案:

答案 0 :(得分:0)

How about this xpath?

=IMPORTXML(A1, "//span[@id='ajaxPrice']/@content")
  • Cell "A1" has the URL of https://homedepot.com/p/206651614.

enter image description here

If this was not the result you want, I apologize. At that time, can you tell me about the value you want? I would like to modify it.

答案 1 :(得分:0)

you can do it like this too:

=REGEXEXTRACT(QUERY(ARRAY_CONSTRAIN(
 IMPORTDATA("https://homedepot.com/p/206651614"), 1500, 1), 
 "where Col1 contains 'ciItemPrice'"), "\d+.\d+|\d+")

0