class OverwatchStats::StatScraper
Public Class Methods
current()
click to toggle source
# File lib/statscraper.rb, line 3 def self.current self.scrape_all_stats end
scrape_all_stats()
click to toggle source
# File lib/statscraper.rb, line 7 def self.scrape_all_stats doc = Nokogiri::HTML(open("http://masteroverwatch.com/heroes")) container = doc.css("div.table-body") stats = [] counter = 0 container.css("div.table-row-content").each do |x| counter = counter + 1 if counter >= 1 && counter <= 21 hero_name = x.css("div.table-name span.table-name-block strong").text hero_type = x.css("div.table-name span.table-name-block small").text hero_winrate = x.css("div.table-winrate div.bar-outer").text hero_popularity = x.css("div.table-popularity div.bar-outer").text hero_kd = x.css("div.table-kd-ratio div.bar-outer").text hero_medalpergame = x.css("div.table-medals-game div.bar-outer").text stats << {:heroname => hero_name, :herotype => hero_type, :winrate => hero_winrate, :popularity => hero_popularity, :medalpergame => hero_medalpergame, :herokd => hero_kd} end end stats end