Created
August 8, 2014 02:44
-
-
Save joellusky/291b18862ade294948ec to your computer and use it in GitHub Desktop.
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 '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