Skip to content

Instantly share code, notes, and snippets.

@aguayma
Created January 28, 2015 20:06
Show Gist options
  • Save aguayma/99f541c3a38315509715 to your computer and use it in GitHub Desktop.
Save aguayma/99f541c3a38315509715 to your computer and use it in GitHub Desktop.
ticker_on_localhost
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