Skip to content

Instantly share code, notes, and snippets.

@JosephLeon
Created May 1, 2016 00:46
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 JosephLeon/6b421790b3bd353945f80f31c687f34a to your computer and use it in GitHub Desktop.
Save JosephLeon/6b421790b3bd353945f80f31c687f34a to your computer and use it in GitHub Desktop.
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