Skip to content

Instantly share code, notes, and snippets.

@barlino
Created June 21, 2012 07:03
Show Gist options
  • Save barlino/2964321 to your computer and use it in GitHub Desktop.
Save barlino/2964321 to your computer and use it in GitHub Desktop.
Spellcheck via Google API in Ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'http_request'
require 'builder'
class Net::HTTP
alias_method :old_initialize, :initialize
def initialize(*args)
old_initialize(*args)
@ssl_context = OpenSSL::SSL::SSLContext.new
@ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
end
res = HttpRequest::get(
:url => 'http://www.google.com.tw/search?hl=zh-TW&q=' + CGI.escape("tam kruize")
)
resp = res.body
if resp =~ /<span\s+class=spell\s+style="color:#000000">.*?<\/span>(<a .*?><\/a>)/
puts $~
puts $1
puts $2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment