I am trying to pull the "low price" from this web page url https://www.nbatopshot.com/listings/p2p/208ae30a-a4fe-42d4-9e51-e6fd1ad2a7a9+2d0fe5aa-617a-4492-89d2-faa125e4b196
using Google Sheets XImport.
I copied the xPath from the developer console which returns this:
//*[@id="__next"]/div/main/div[3]/div/div[3]/div/div[2]/div[1]/div[1]/span
However my formula when putting those two together does now work and returns "imported content is empty message).
Can anyone help?
Try this:
=VALUE(REGEXEXTRACT(IMPORTXML("https://www.nbatopshot.com/listings/p2p/208ae30a-a4fe-42d4-9e51-e6fd1ad2a7a9+2d0fe5aa-617a-4492-89d2-faa125e4b196","html/head/title"),"USD .([\d,]+)"))
As for the IMPORTXML itself, the extraction isn't from the body of the HTML. At a glance, what you see in the body seems to be generated by script, which you would not be able to retrieve. But it also looks like PHP is generating the static header title from that same data in this case, so I was able to retrieve it from there. (I found this in Chrome by right-clicking on the page and doing a 'Find' for "Lebron.")
REGEXEXTRACT
pulls just the low figure, and VALUE
converts it to a usable number.