Skip to content

Instantly share code, notes, and snippets.

@NuckChorris
Created August 20, 2013 04:27
Show Gist options
  • Select an option

  • Save NuckChorris/6277112 to your computer and use it in GitHub Desktop.

Select an option

Save NuckChorris/6277112 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
require 'pp'
doc = Nokogiri::HTML(open("http://www.animecalendar.net//"))
episodes = []
doc.css('#calendarContent .day').each do |day|
date = Date.strptime(day.at_css('th a')['href'], "/%Y/%m/%d")
day.css('.tooltip').each do |ep|
title = ep.css('.tooltip_title h4').text.strip
desc = ep.css('.tooltip_desc').text.strip
info = ep.css('.tooltip_info').text.strip
info = /Ep:\s+(?<episode>\d+)\s+at\s+(?<time>\d+:\d+)\s+on\s+(?<station>.*)/.match(info)
airtime = DateTime.strptime("#{date.to_s}T#{info[:time]}+9", '%Y-%m-%dT%H:%M%z')
episodes << {
:title => title,
:desc => desc,
:episode => info[:episode],
:airtime => airtime,
:station => info[:station]
}
end
end
pp episodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment