Created
May 1, 2016 00:46
-
-
Save JosephLeon/6b421790b3bd353945f80f31c687f34a 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 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
puts "Enter stock ticker" | |
ticker = gets.chomp | |
BASE_YAHOO_URL = "http://finance.yahoo.com" | |
LIST_URL = "#{BASE_YAHOO_URL}/q?s=#{ticker}" | |
puts LIST_URL | |
cleaned_ticker = ticker.downcase | |
stock_ticker_element = "#yfs_184_#{cleaned_ticker}" | |
puts stock_ticker_element | |
page = Nokogiri::HTML(open(LIST_URL)) | |
stock_price = page.css('#yfs_l84_f') | |
# stock_price = page.css(stock_ticker_element) | |
# puts page | |
puts stock_price |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment