Skip to content

Instantly share code, notes, and snippets.

@dwabyick
Created August 15, 2012 18:13
Show Gist options
  • Save dwabyick/3362045 to your computer and use it in GitHub Desktop.
Save dwabyick/3362045 to your computer and use it in GitHub Desktop.
Basic YouTube ID parser for an HTML page
#!/usr/bin/ruby
require 'uri'
require 'net/http'
# Output YouTube ID's, one per line from a URL.
url = 'http://www.youtube.com/'
res = Net::HTTP.get_response( URI.parse( url ) )
reg = /href="\/watch\?v=([^"|^&]*)/
matches = res.body.scan( reg )
matches.uniq!
puts matches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment