Created
October 3, 2013 18:41
-
-
Save pricees/6814856 to your computer and use it in GitHub Desktop.
MSN Money (10 year summary, 10 year key ratios)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13:37 $ cat parse.rb | |
require "nokogiri" | |
require "awesome_print" | |
def ten_year_key_ratios | |
# investing.money.msn.com/investments/key-ratios?symbol=aapl&page=TenYearSummary | |
doc = Nokogiri::HTML File.read("./10_yr_key_ratios") | |
data = [] | |
doc.css("table.mnytbl tr").each do |n| | |
foo = n.search('th/span').map { |x| x.text.strip } | |
data << foo if foo.any? | |
bar = n.search('td/span').map { |x| x.text.strip } | |
data << bar if bar.any? | |
end | |
ap data | |
end | |
def ten_year_summary | |
# http://investing.money.msn.com/investments/financial-statements?symbol=aapl | |
doc = Nokogiri::HTML File.read("./10_yr_summary") | |
data = [] | |
doc.css("table.mnytbl").each do |n| | |
n.search('thead/tr').each do |m| | |
foo = m.search('/th/span').map { |x| x.text.strip } | |
data << foo if foo.any? | |
end | |
bar = n.search('tbody/tr/td/span').map { |x| x.text.strip } | |
data << bar if bar.any? | |
end | |
ap data | |
end | |
#ten_year_key_ratios | |
ten_year_summary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Jim. "If" this still works (this is 7 years old), you could quickly test it by:
Best of luck. It should download 10 year financials for Apple (see L6:
aapl
)