Skip to content

Instantly share code, notes, and snippets.

@rubydoc
Last active December 28, 2015 06:49
Show Gist options
  • Save rubydoc/7459721 to your computer and use it in GitHub Desktop.
Save rubydoc/7459721 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'nokogiri'
require 'pp'
require 'active_support/all'
class Video
def initialize item
@title = item.css(".yt-lockup-title").at_css("a").try(:text)
# @thumb_url = item.css(".video-thumb").at_css("img")[:src]
# @url = "http://www.youtube.com" + item.css(".yt-lockup-thumbnail").at_css("a")[:href]
pp @title#, @thumb_url, @url
end
def self.crawl_from channel
page = Nokogiri::HTML(open(channel).read)
page.css(".channels-content-item").each do |item|
new(item)
end
end
end
Video.crawl_from 'http://www.youtube.com/user/ongdalssam'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment