Skip to content

Instantly share code, notes, and snippets.

@burnto
Created December 8, 2009 08:10
Show Gist options
  • Save burnto/251512 to your computer and use it in GitHub Desktop.
Save burnto/251512 to your computer and use it in GitHub Desktop.
grab retarded youtube comments for category or keyword
require 'rubygems'
require 'hpricot'
require 'open-uri'
n = ARGV[0]
n = n.gsub(/\s+/, "%2C%2D")
xml = open("http://gdata.youtube.com/feeds/api/videos?category=#{n}").read
doc = Hpricot::XML(xml)
links = doc.search("//gd:feedLink").map{|fl| fl.attributes["href"]}
comments = links.map { |link|
xml = open(link)
doc = Hpricot::XML(xml)
doc.search("//entry/content").map do |c|
c.inner_html
end
}.flatten
puts "<html><head></head><body>"
puts "<h1>#{n}</h1>"
puts comments.map{|x| "<p>#{x}</p>"}
puts "</body></html>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment