Skip to content

Instantly share code, notes, and snippets.

@bigfleet
Created February 10, 2010 15:41
Show Gist options
  • Select an option

  • Save bigfleet/300452 to your computer and use it in GitHub Desktop.

Select an option

Save bigfleet/300452 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'set'
img_urls = Set.new
[0,20,40,60,80,100,120,140,160,180,200].each do |val|
url = "http://images.google.com/images?as_st=y&hl=en&q=avatar+imagesize:150x150&sa=N&start=#{val}&ndsp=20"
results = open(url)
str = open(results).read
str.scan(/http:\/\/([^\"]*)\.(gif|jpg|png)/).collect{ |m| "http://"+m.join('.') }.each do |item|
img_urls << item
end
end
puts img_urls.entries.inspect
puts img_urls.entries.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment