-
-
Save franckverrot/201225 to your computer and use it in GitHub Desktop.
This file contains 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
require "rubygems" | |
require "hpricot" | |
require "open-uri" | |
class TvRage | |
def self.full_schedule(country='US') | |
doc = self.fetch_xml('http://services.tvrage.com/feeds/fullschedule.php', 'country' => country, '24_format' => '1') | |
p "full_schedule - #{doc.class}" | |
doc.search('//show').each {|show| process_show(show) } | |
end | |
def self.fetch_xml(url, params={}) | |
uri = url | |
unless params.empty? | |
uri << '?' + params.to_a.collect { |param| param.join('=') }.join('&') | |
end | |
doc = open(uri) do |file| Hpricot::XML(file) end | |
p "fetch_xml - #{doc.class}" | |
return doc | |
end | |
def self.process_show(show_node) | |
p show_node.to_s | |
end | |
end | |
TvRage.full_schedule |
This file contains 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
Output: different, but seems to work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment