Skip to content

Instantly share code, notes, and snippets.

@hirakuro
Created October 17, 2009 07:21
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 hirakuro/212278 to your computer and use it in GitHub Desktop.
Save hirakuro/212278 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "rack"
class GoogleCrawlerCollector
def save_log
open("log.log", "a") do |f|
f.puts "-"*40, Time.now
f.puts @req.env.map{|k, v| "#{k}: #{v}"}.sort.join("\n"), ""
end
end
def build_response
@res.write <<EOT
<html>
<head><title>Google crawler collect</title></head>
<body>
<p>Thank you :-)</p>
</body>
</html>
EOT
end
def call(env)
@req = Rack::Request.new(env)
@res = Rack::Response.new
save_log
build_response
@res.finish
end
end
Rack::Handler::CGI.run Rack::Builder.app{
use Rack::ShowExceptions
use Rack::Lint
run GoogleCrawlerCollector.new
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment