Created
November 18, 2012 19:39
-
-
Save jvenator/4107086 to your computer and use it in GitHub Desktop.
YouTube Scraping
This file contains hidden or 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 'nokogiri' | |
require 'open-uri' | |
puts "What YouTube URL do want information on?" | |
url = gets.chomp | |
doc = Nokogiri::HTML(open(url)) | |
subscribers = doc.css('span.stat-value')[0].content | |
views = doc.css('span.stat-value')[1].content | |
puts "This channel has " + subscribers + " subscribers and " + views + " total views" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment