Skip to content

Instantly share code, notes, and snippets.

@kzaitsev
Created February 10, 2014 21:37
Show Gist options
  • Save kzaitsev/8924701 to your computer and use it in GitHub Desktop.
Save kzaitsev/8924701 to your computer and use it in GitHub Desktop.
sochi 2014
require 'nokogiri'
require 'excon'
require 'active_support/time'
require 'pp'
sch = []
(2..17).each do |day|
day_of_month = day + 6
response = Excon.get("http://www.sochi2014.com/ezhednevnoe-raspisanie-den-#{day}")
page = Nokogiri::HTML(response.body)
page.css('.b-competitions-dated-previews-section').each do |discipline|
games = discipline.css('.b-competitions-dated-previews-collection-inside')
game = {}
# Games
games.css('tr.b-competitions-dated-previews-collection-clause').each do |current_game|
# Start
start_time = current_game['data-selection-article-beginning-time'].split(':')
start_game = Time.new('2014', '02', day_of_month, start_time.first, start_time.last)
# End
end_game = start_game + 2.hours
# Name
game_name = current_game.css('.b-competitions-dated-previews-collection-clause-title-cell a.b-competitions-dated-previews-collection-clause-cell-link').text
game.merge!(start_game: start_game.to_s, end_game: end_game.to_s, category: discipline.css('.title.simple span.outer a.sport.small.white.inner').text, name: game_name)
sch << game
end
end
end
pp sch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment