Created
January 28, 2015 20:06
-
-
Save aguayma/99f541c3a38315509715 to your computer and use it in GitHub Desktop.
ticker_on_localhost
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
require 'sinatra' | |
require 'httparty' | |
require 'json' | |
require 'nokogiri' | |
get '/' do | |
response = HTTParty.get('http://finance.yahoo.com/q?s=AAPL') | |
dom = Nokogiri::HTML(response.body) | |
span = dom.xpath("//span[@id='yfs_l84_aapl']").first | |
price = span.content | |
p "The current price of AAPL is $#{price}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment