Skip to content

Instantly share code, notes, and snippets.

@bugcloud
Created August 12, 2011 04:48
Show Gist options
  • Save bugcloud/1141479 to your computer and use it in GitHub Desktop.
Save bugcloud/1141479 to your computer and use it in GitHub Desktop.
make you hot
require 'net/http'
require 'uri'
BIJIN = "www.bijint.com"
now = Time.now
#puts "choose your favorite prefecture, jp/gal/hokkaido/sendai/kobe/kyoto/fukuoka/nagoya"
#pref = gets.chomp!
pref = "jp"
dir = "#{ENV['HOME']}/Desktop"
begin
Net::HTTP.start(BIJIN, 80){|http|
res = http.get("/#{pref}/tokei_images/#{(now.hour/10 < 1)? "0" : ""}#{now.hour}#{(now.min/10 < 1)? "0" : ""}#{now.min}.jpg", {"Referer" => "http://www.bijint.com/#{pref}/"})
open("#{dir}/#{now.to_s}.jpg", "wb"){|file|
file.puts res.body
}
}
rescue
p "failed to get image."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment