Skip to content

Instantly share code, notes, and snippets.

@acammack
Created September 20, 2011 17:33
Show Gist options
  • Save acammack/1229745 to your computer and use it in GitHub Desktop.
Save acammack/1229745 to your computer and use it in GitHub Desktop.
Pulls stuff down from a page.
#!/usr/bin/env ruby
require "rubygems"
# require your gems as usual
require "nokogiri"
require 'open-uri'
doc = Nokogiri::HTML.parse open('http://cs.ecs.baylor.edu/~mia/courses/3303_201103/csi3303Review1/csi3303review1.html')
#this works to here
####
# Search for nodes by xpath
divs = doc.xpath("//div")
regex = />\s*([0-9]+)\)&nbsp;\s*<\/TD>/ix
questions = divs.map do |record|
content = record.content
if (regex =~ content) && (ARGV.include? $1)
record
end
end
puts (ARGV.sort.zip questions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment