Skip to content

Instantly share code, notes, and snippets.

@pricees
Created October 3, 2013 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pricees/6814856 to your computer and use it in GitHub Desktop.
Save pricees/6814856 to your computer and use it in GitHub Desktop.
MSN Money (10 year summary, 10 year key ratios)
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
@jimchalk
Copy link

hi, do you have instructions on how to this run code? thanks

@pricees
Copy link
Author

pricees commented Mar 23, 2020

hi, do you have instructions on how to this run code? thanks

Hey Jim. "If" this still works (this is 7 years old), you could quickly test it by:

# install ruby
# install rubygems
# download parse.rb
$ gem install nokogiri awesome_print
$ ruby parse.rb

Best of luck. It should download 10 year financials for Apple (see L6: aapl)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment