Skip to content

Instantly share code, notes, and snippets.

@jahan-paisley
Created August 25, 2012 13:24
Show Gist options
  • Save jahan-paisley/3465623 to your computer and use it in GitHub Desktop.
Save jahan-paisley/3465623 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'uri'
require 'nokogiri'
require 'open-uri'
$address = 'http://www.asia.si.edu/archives/finding_aids/sevruguin.html'
$path = "~/Downloads/"
url = URI.parse($address)
puts "downloading"
doc = Nokogiri::HTML(open($address))
puts "downloaded"
doc.css('a[href*=jpg]').each do |link|
puts link.methods if i==0
puts link
Net::HTTP.start(url.host, url.port) {|http|
File.open($path+ File.basename(link['href']), "w+b", 0644){|f|
f.write http.get(link['href']).body
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment