class StocksInfo::Scraper

Public Class Methods

scrape(ticker) click to toggle source
# File lib/stocks-info/scraper.rb, line 3
def self.scrape(ticker)
    ticker.html = Nokogiri::HTML(open("#{ticker.url}"))
    ticker.name = ticker.html.css("#quote-header-info h1").text
    ticker.price = ticker.html.css("#quote-header-info span")[1].text
    ticker.price_change = ticker.html.css("#quote-header-info span")[2].text
    ticker.news = ticker.html.css("#quoteNewsStream-0-Stream a")
end