Grabbing a result from Google with Nokogiri

1. Install Nokogiri

gem install nokogiri

2. and use it like this

require 'open-uri'
require 'nokogiri'
require 'cgi'

url = "http://www.google.com/search?q=#{CGI.escape(query)}"
res = Nokogiri::HTML(open(url)).at("h3.r")

title = res.text
link = res.at('a')[:href]
desc = res.at("./following::div").children.first.text

These help:
Nokogiri tutorials: http://nokogiri.org/tutorials
and: http://stackoverflow.com/questions/14912392/how-do-i-parse-google-image-urls-using-ruby-and-nokogiri