Find the Xpath to get data with importxml function - xpath

I want to use ImportXML function in google sheets in order to bring some prices into my google sheet, how to find the correct Xpath for this ?
This is the URL: https://super.walmart.com.mx/verduras/aguacate-hass-extra-por-kilo/00000000003354
and im trying to bring the price, in this case is $39.90
I was trying this formula but im getting NA (imported content is empty)
=IMPORTXML("https://super.walmart.com.mx/verduras/aguacate-hass-extra-por-kilo/00000000003354","//*[#id="scrollToTopComponent"]/section/div[1]/div[2]/div[2]/div[3]/h4/text()[1]")
Thanks

IMPORTXML does not work on Javascript content
You can verify that that the URL https://super.walmart.com.mx/verduras/aguacate-hass-extra-por-kilo/00000000003354 content loads via Javascript by
going on your Browser settings
Disable / block Javascript
Refresh your URL
See the following:
So, unfortunately you cannot use IMPORTXML to get the content of this URL.

Related

How to scrape price from mercari in google sheet using importxml?

I would like to get the "3,776" price in this website.
https://jp.mercari.com/item/m68422230699
I copy the full xpath, but it returs #N/A
=IMPORTXML("https://jp.mercari.com/item/m68422230699","/html/body/div[1]/div[1]/div/div/div/main/article/div[2]/section[1]/section[1]/div/mer-price//span[2]")
#N/A, in this case, is a result of trying to scrape JavaScript content/elements which Google Sheets does not support. you can test this simply by disabling JS for a given site and what's left can be scraped. in your case it's nothing:

How to find the correct Xpath to get importxml function work

I'm trying to use ImportXML function in Google sheets in order to bring some prices into my Google sheet, how to find the correct Xpath for this?
This is the URL:
https://www.superama.com.mx/catalogo/d-frutas-verduras/f-frutas/l-naranja-limon-y-citricos/mandarina-por-kilo/0000000003029
and I'm trying to bring the id="lblPrice" which in this case is $24.90
I was trying this formula but I'm getting NA
=IMPORTXML("https://www.superama.com.mx/catalogo/d-frutas-verduras/f-frutas/l-naranja-limon-y-citricos/mandarina-por-kilo/0000000003029","//*[#id="lblPrice"]")
IMOPORTXML/Google Sheets does not support scraping of JavaScript elements.

Using Google Sheets for web scraping. Need the correct xpath for IMPORTXML function

There is a google sheet containing a list of MPN's (manufacturer part numbers). Trying to scrape a site called wikiarms for the UPC Codes when I have the MPN for an item.
I have the correct formula for doing this on another site.
=IMPORTXML("http://gun.deals/search/apachesolr_search/"&B1,"//dd/a[../../dt[contains(text(),'UPC')]]|//dd/span[../../dt[contains(text(),'UPC')]]")
Trying to figure out what the correct xpath to complete this formula. Some videos I have watch said to open the page in Chrome and use inspector to select and copy the xpath to complete the importxml function. I tried this with no luck.
Sample
Visit https://www.wikiarms.com/guns?q=20071
In the table there is a button "available in 6 stores" click that to reveal the list. The UPC should be listed after the MPN.
If I copy the xpath in Chrome this is the result
/html/body/div[1]/div/div/div[2]/div/div/div[2]/div[2]/table/tbody/tr[2]/td[5]
=IMPORTXML("https://www.wikiarms.com/guns?q="&B2,"xpath here")
What do I have to add at the end of this formula to pull in the UPC code? I will be using this formula to pull in UPC code for about 1000 items.
Thank you for your help.
Using your sample link, try
=IMPORTXML("https://www.wikiarms.com/guns?q=20071","//td[#class='upc']/a/#title")
and see if it works for you.

Can't get the data using importXML from Dynamic Web Page?

The website is : https://www.futbin.com/18/player/2600/Ayhan/
I inspect the element and get the XPath which is: //*[#id="ps-lowest-1"]
Then I use:
=IMPORTXML("https://www.futbin.com/18/player/2600/Ayhan/","//*[#id='ps-lowest-1']")
To get the data which should be 2000
But instead it only shows: - on the sheet. No errors just doesn't show the data that I want it to. Is there anyway to get the data that I need?
Thanks
The Sheets command importXML reads only the HTML source of the page without executing any JavaScript on it. As you can see yourself by using "view source" in the browser, the source indeed has "-" in that span:
<span class="price_big_right">
<span id="ps-lowest-1">-</span>
</span>
The actual numbers are loaded by some JavaScript file which then inserts them in that span. Neither importXML nor other Sheets functions can retrieve dynamically inserted data.
Sometimes, after inspecting the JS files, one can uncover the URL of source of data and try to import that; but this is a tedious reverse engineering exercise for each particular site.

Importxml Imported Content Empty

I encounter the error message imported content is empty when I use the formula below in google spreadsheet.
=IMPORTXML("https://www.moh.gov.sg/content/moh_web/home/pressRoom.html", "//div[#class='article highlight']/h3/a/#title")
I am trying to import the list of press release title on the webpage.
What am I doing wrong?
So this issue is not your formula or XML in this particular case, its that the content is loaded using jQuery, so you need to figure out where or what the url is that actually holds your content.

Resources