1

I'm trying to get my investment portfolio tracker on Google Sheets going but running into a snag.

Link: https://money.tmx.com/en/quote/BCE/key-data

There is a section called "Dividend" and I want to grab the Dividend Yield and here is my code

=IMPORTXML("https://money.tmx.com/en/quote/BCE/key-data","//div[@class='sc-hLyhSY bJCEDS']/div/span")

I tried using an chrome extension called SelectorGadget, doesn't seem to work either.

Rubén
  • 34,714
  • 9
  • 70
  • 166
gd6noob
  • 11
  • 2

1 Answers1

1

This website's content is added dynamically via JavaScript, and hence it requires JavaScript to be enabled in order to render. Because of this, you cannot import its content via sheets built-in functions like IMPORTXML.

You can check that's the case if you disable JavaScript on your browser (for example, using Chrome DevTools), and then refresh the page. All you'll see is the following message:

You need to enable JavaScript to run this app.

You can also notice this if you try to import the whole body:

=IMPORTXML("https://money.tmx.com/en/quote/BCE/key-data","//body")

The imported content is the previous message as well as JavaScript code, no other HTML content.

Related threads:

Iamblichus
  • 18,540
  • 2
  • 11
  • 27