1
votes

This URL: https://www.screwfix.com/p/makita-jr3050t-2-1010w-reciprocating-saw-240v/27338

Trying to use IMPORTXML on google Sheets to pull in the price (119.99 as of today)

Using the following formula:

(via Google Developer Tab, right-click Copy XPath)

=IMPORTXML(https://www.screwfix.com/p/makita-jr3050t-2-1010w-reciprocating-saw-240v/27338, "//*[@id='product_price']/text()")

Or

=IMPORTXML("https://www.screwfix.com/p/makita-jr3050t-2-1010w-reciprocating-saw-240v/27338","//meta[@itemprop='price']/@content")

Or

=importxml(https://www.screwfix.com/p/makita-jr3050t-2-1010w-reciprocating-saw-240v/27338, "//div[@class='pr__price']")

Plus a few other variations - Unfortunatley, they all come out as #N/A

Can anyone help me find the correct path?

1

1 Answers

0
votes

It seems that in this case, when the URL is retrieved by IMPORTXML(), most values are included in head. When I tried this URL, body retrieved by IMPORTXML() was empty. So how about this workaround?

=REGEXEXTRACT(IMPORTXML(A1,"//head/*"),"(\d.+)INC")
  • Please put the URL of https://www.screwfix.com/p/makita-jr3050t-2-1010w-reciprocating-saw-240v/27338 to the cell "A1" and put the formula to other cell.
  • In this workaround, the value you want is retrieved from the values retrieved from head.

Result:

enter image description here

Note:

  • I'm not sure whether this formula can be used for other URL. If you want to use this for other URL, please confirm the values and set the xpath and regex.
  • If you use Google Apps Script, I think that the value can be retrieved from the body of URL.

If this was not what you want, I'm sorry.