Search code examples
apigoogle-sheetsgoogle-sheets-formulastock

Struggling to import analyst share price to GoogleSheets


I am trying to create a column that imports the analyst price target from TipRanks website. I uploaded two images:

Image 1: you can see the cell that I want to import.

Image 2: you can see my function that doesn't work.

What should I change in order to get this live info? Thanks.


Solution

  • The site you are checking is actually "javascript" generated thus import functions won't properly work on them.

    To check, just try to import the whole site data. If it returns a javascript function, then it is javascript generated.

    Sample (tipranks.com)

    Sample

    What you can do is actually try to find other sites that provide the same data.

    I did find one with the same data you are looking for, 50.38 for csiq. Link is "https://www.marketwatch.com/investing/stock/csiq/analystestimates". And since data is shown as table, it would be easier to import using importhtml.

    Cell formula is: =INDEX(IMPORTHTML("https://www.marketwatch.com/investing/stock/csiq/analystestimates", "table", 5), 2, 2)

    Sample output: sample output

    The table is the fifth one in the DOM, and INDEX(table, 2, 2) means getting the 2nd row 2nd column of the table.

    If the site is no good for you, you can try finding other sites that would suit your needs. And then use either importhtml or importxml depending on the site structure.