r/ScriptSwap • u/greenbartrading • Nov 29 '14
[REQUEST] Parse HTML from company financial statements
Hello,
I am wondering if someone could help me develop a script to parse data from an HTML table like the ones here (see item 8, the income statement). Basically what I'm trying to do is pull that data (net income, revenue, various expenses etc) into a google spreadsheet so that I can run some calculations on it.
I wrote a similar script in Python a while ago that scraped data from Yahoo Finance's financial statements but it is dependent on Yahoo's formatting and I would trust that the default formatting from Edgar is much more likely to remain the same than Yahoo's, though Yahoo hasn't changed theirs in a while either.
Anyway just looking for some guidance or advice if anyone has a better way to do this. Basically I have a series of checks I want to perform against revenues, profit margins, various ratios, etc and it would be much easier to run those checks if I could use the raw financial data in my spreadsheet. Most of the APIs I have found (Yahoo Finance, Morningstar, Google Finance so far) only provide quote data like bid, ask, close, open, % change, and basic fundamental data like PE ratio and the like. Also they don't provide any access to historical data unless it is quote data, so I can't determine any trends in fundamental data.
Ok, hopefully that's enough info. Any advice? Thanks!!!
Chris
View all comments
Show parent comment
1
u/worksafeforposterity Nov 30 '14
what variable is getting 'index out of range' error? if it's your row-grabbing logic, it's probably grabbing the wrong table & no further rows exist. does the table you're interested in have an 'id' or a 'class' attribute? (you can check by right-clicking the table & 'inspect element'ing)