Last active
December 28, 2015 06:49
-
-
Save rubydoc/7459721 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 '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