Skip to content

Instantly share code, notes, and snippets.

@pdabrowski6
Created June 14, 2018 04:55
Show Gist options
  • Save pdabrowski6/e1982e00a280bc5be409a0ef410ce5cc to your computer and use it in GitHub Desktop.
Save pdabrowski6/e1982e00a280bc5be409a0ef410ce5cc to your computer and use it in GitHub Desktop.
Code for checking Ruby Rogues stats
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