Skip to content

Instantly share code, notes, and snippets.

@kimihito
Last active December 28, 2015 23:59
Show Gist options
  • Save kimihito/7582904 to your computer and use it in GitHub Desktop.
Save kimihito/7582904 to your computer and use it in GitHub Desktop.
1日ごとで見られたYouTubeのデータを取得する
require 'open-uri'
require 'nokogiri'
uri = URI("https://gdata.youtube.com/feeds/api/standardfeeds/JP/most_recent?time=today&v=2").read
docs = Nokogiri::XML(uri)
entry = docs.search("entry")
entry.each do |attr|
puts attr.search("title")
puts attr.xpath("media:group").xpath("media:thumbnail").attr("url")
puts attr.xpath("media:group").xpath("yt:videoid").text
puts attr.xpath("media:group").xpath("media:category").text
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment