How to get Soybean commodity price into Google Sheet: Simple solution

139 views Asked by At

I went here: https://tradingeconomics.com/commodity/soybeans

I inspect element of the soybean price, visible on the right side. enter image description here

Then I find the number in the dev tools panel, right click and copy Xpath, or copy full xpath.

enter image description here

Then I passed the xpath into a fomula.

  1. =IMPORTXML("https://tradingeconomics.com/commodity/soybeans", "//*[@id="p"]/text()")

OR

  1. =IMPORTXML("https://tradingeconomics.com/commodity/soybeans", "/html/body/form/div[6]/div/div[2]/div/div[1]/div[1]/div/div/div[1]/table/tbody/tr[9]/td[2]/text()")

But I get an error either #NA or #ERROR!

Later I tried here:https://www.indexmundi.com/commodities/?commodity=soybeans&months=60

But this also didn't work:

=IMPORTXML("https://www.indexmundi.com/commodities/?commodity=soybeans&months=60", "//*[@id="futuresPanel"]/span")

1

There are 1 answers

0
Lorena Gomez On

I also made several tests with that site and got the error:

Could not fetch url: https://tradingeconomics.com/commodity/soybeans

The issue is that the data you're trying to import is dynamically loaded. This data is loaded by JavaScript, therefore is not retrievable by IMPORT functions in Google Sheets. You can refer to this thread for more details.

I also found another thread regarding the same website and reports the same issue, it seems the website does not allow web scraping.