1

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")

Lorena Gomez
  • 1,946
  • 2
  • 4
  • 11
dlight
  • 29
  • 3
  • worked on https://www.investing.com/commodities/us-soybeans-related-instruments – dlight May 29 '23 at 20:31
  • if [this](https://stackoverflow.com/a/76360245/17926478) answer actually worked for you (at least for your initial concern), don't forget to either upvote or mark it as 'best answer'. By doing so, other people in the community, who may have the same concern as you, will know that theirs can be resolved. – Lorena Gomez May 30 '23 at 19:55

1 Answers1

0

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.

Lorena Gomez
  • 1,946
  • 2
  • 4
  • 11