Skip to content

Instantly share code, notes, and snippets.

@koyachi
Created July 14, 2010 21:45
Show Gist options
  • Save koyachi/476141 to your computer and use it in GitHub Desktop.
Save koyachi/476141 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
$KCODE = 'UTF8'
require 'rubygems'
require 'google-search'
query = ARGV[0] || "paris hilton"
HTML = File.dirname(__FILE__) + '/face.html'
open(HTML, 'w') do |file|
file.write <<-"HEADER"
<html>
<title>search face: #{query}</title>
<body/>
HEADER
Google::Search::Image.new(:query => query, :imgtype => 'face').each do |image|
file.write %!<img src="#{image.uri}">!
end
file.write <<-"FOOTER"
</body>
</html>
FOOTER
end
begin
`open -a Safari #{HTML}`
rescue
puts "Not on OSX? wtf? open #{HTML} in your browser to view the images"
end
__END__
http://github.com/visionmedia/google-search
http://d.hatena.ne.jp/phac/20080512/1210611989
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment