Created
July 14, 2010 21:45
-
-
Save koyachi/476141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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