Skip to content

Instantly share code, notes, and snippets.

@danhigham
Created January 15, 2011 15:03
Show Gist options
  • Save danhigham/780960 to your computer and use it in GitHub Desktop.
Save danhigham/780960 to your computer and use it in GitHub Desktop.
Downloads files from a page if they are pdf or zip!
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
doc = Hpricot(open('http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2010-winter'))
(doc/"a").each do |x|
href = x.attributes['href']
`wget #{href}` if href.grep(/.pdf|.zip/)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment