Skip to content

Instantly share code, notes, and snippets.

@elight
Created November 25, 2010 20:02
Show Gist options
  • Select an option

  • Save elight/715837 to your computer and use it in GitHub Desktop.

Select an option

Save elight/715837 to your computer and use it in GitHub Desktop.
require 'nokogiri
require 'open-uri'
io = open 'http://slashdot.org'
text = io.read
doc = Nokogiri::HTML::Document.parse(text)
# Just in case you didn't know, "#<some id here>" is a CSS selector for locating an HTML element by ID
doc.css("#top_parent a").count
# voila!
@TonyRockyHorror

Copy link
Copy Markdown

Beautiful! Thanks a ton! I'm still a total r00bn00b, but I'm learning!

@elight

elight commented Nov 25, 2010

Copy link
Copy Markdown
Author

Noko is your best buddy for HTML and XML parsing. It wraps libxml and is wicked fast, powerful, and elegant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment