Created
September 20, 2011 17:33
-
-
Save acammack/1229745 to your computer and use it in GitHub Desktop.
Pulls stuff down from a page.
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
#!/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]+)\) \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