Sha256: 6ebb4b8b398deb6247c93c409f24fc3e53aa89422237eaa3bcc2563023ace943
Contents?: true
Size: 558 Bytes
Versions: 1
Compression:
Stored size: 558 Bytes
Contents
class DjiScraper def scrape doc = Nokogiri::HTML(open(StockIndex::ATTRIBUTES['^DJI'][:url])) doc.css('table.wikitable.sortable tr').inject([]) do |array, tr| string = "#{market(tr)}:#{symbol(tr)}" array << string unless string == ":" array end end private def symbol(tr) symbol_td = tr.css('td')[2] symbol_td ? symbol_td.css('a').text : nil end def market(tr) market_td = tr.css('td')[1] market = market_td ? market_td.css('a').text : nil StockIndex::Market.new(market).to_iso10383 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stock_index-0.5.0 | lib/stock_index/scrapers/dji_scraper.rb |