0

I am trying to export financial data - Net Income, for instance - using FINVIZ on this page: https://elite.finviz.com/quote.ashx?t=A&ty=c&p=d&b=1

I am able to grab other information from this page using the following formula: =index(IMPORTHTML("http://finviz.com/quote.ashx?t="& $A2,"table",8),3,4) using GOOGLE SHEETS

This doesn't work for the financial information because I can't determine what the table number is.

Thanks for any help.

  • It seems that table is generated with javascript so would need to get using json – JohnA Jul 01 '21 at 17:06
  • can i use json with IMPORTHTML or is that only used with Python? Thanks so much. – Beth Reynolds Jul 02 '21 at 18:21
  • you can use json with google app script as shown in the example I provided. I am guessing Python as well. I have not played with Python yet, it is on my to-do list to learn. – JohnA Jul 03 '21 at 21:17

1 Answers1

0

I am answering your comment question here as it has a script example using json in google app script

function growthEstimate(code){
  var url='https://finance.yahoo.com/quote/'+code+'/analysis'
  var source = UrlFetchApp.fetch(url).getContentText()
  var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
  var data = JSON.parse(jsonString)
  return data.context.dispatcher.stores.QuoteSummaryStore.earningsTrend.trend[4].growth.fmt
}
function testGrowth(){
  Logger.log(growthEstimate('AAPL'))
}
JohnA
  • 1,058
  • 6
  • 12
  • Thank you. I tried this in my file and got this error message: TypeError: Cannot read property 'earningsTrend' of undefined growthEstimate @ Jason Sample.gs:6 – Beth Reynolds Jul 03 '21 at 19:21
  • Running the script as written, I get 17.93% in my log. – JohnA Jul 03 '21 at 21:18