Created
December 8, 2009 08:10
-
-
Save burnto/251512 to your computer and use it in GitHub Desktop.
grab retarded youtube comments for category or keyword
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' | |
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