Created
June 21, 2012 07:03
-
-
Save barlino/2964321 to your computer and use it in GitHub Desktop.
Spellcheck via Google API in Ruby
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 | |
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