Skip to content

Instantly share code, notes, and snippets.

@kastner
Created July 26, 2008 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kastner/2560 to your computer and use it in GitHub Desktop.
Save kastner/2560 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'aws/s3'
include AWS::S3
BUCKET = 'your-bucket-name'
AWS::S3::Base.establish_connection!(
:access_key_id => 'your-amazon-access-id',
:secret_access_key => 'your-amazon-access-key'
)
url = "http://www.colourlovers.com/blog/2008/07/25/color-inspiration-106-blue-palettes/"
content = Hpricot.parse(open(url).read)
(content / "img[@src^='http://www.colourlovers.com/images/badges/']").each do |img|
image = img.attributes["src"]
S3Object.store(
image.gsub(/http:\/\/www.colourlovers.com\//,''),
open(image),
BUCKET,
:access => :public_read
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment