Created
June 14, 2018 04:55
-
-
Save pdabrowski6/e1982e00a280bc5be409a0ef410ce5cc to your computer and use it in GitHub Desktop.
Code for checking Ruby Rogues stats
This file contains hidden or 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
data = {} | |
timeouts = [] | |
1.upto(20) do |page| | |
puts "page #{page}" | |
url = "https://devchat.tv/ruby-rogues/page/#{page}" | |
response = RestClient.get(url) | |
html = Nokogiri::HTML(response) | |
html.css("h3.entry-title a").map { |e| e[:href] }.each do |url| | |
begin | |
response = RestClient.get(url) | |
html = Nokogiri::HTML(response) | |
title = html.css("h1.entry-title").text | |
views = html.xpath('//span[contains(@class, "td-nr-views")]').text.to_i | |
data[title] = views | |
rescue RestClient::RequestTimeout | |
timeouts << url | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment