Skip to content

Instantly share code, notes, and snippets.

@jvenator
Created November 18, 2012 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvenator/4107086 to your computer and use it in GitHub Desktop.
Save jvenator/4107086 to your computer and use it in GitHub Desktop.
YouTube Scraping
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