Skip to content

Instantly share code, notes, and snippets.

@joellusky
Created August 8, 2014 02:44
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 joellusky/291b18862ade294948ec to your computer and use it in GitHub Desktop.
Save joellusky/291b18862ade294948ec to your computer and use it in GitHub Desktop.
require 'httparty'
require 'nokogiri'
puts "Enter a stock ticker you would like to"
stock = gets.chomp.downcase
response = HTTParty.get("http://finance.yahoo.com/q?s=#{stock}")
dom = Nokogiri::HTML(response.body)
se = dom.xpath("//span[@id='yfs_l84_#{stock}']").first
price = se.content
puts "The stock you entered just traded at $#{price}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment