title: How to find the href element value in "<a>" tag with ruby
body: <p>My goal is to find the first result in google search resultes and collect the site link, so I built this script: </p>
  
  <pre><code>require 'hpricot'
  require 'open-uri'
  require 'mechanize'
  query = gets.chomp
  agent = Mechanize.new
  page = agent.get("http://www.google.co.il/")
  search_form = page.form_with(:name =&gt; "f")
  search_form.field_with(:name =&gt; "q").value = query.to_s
  search_results = agent.submit(search_form)
  search_results = search_results.body
  doc = Hpricot(search_results)
  site = doc.search("a")[16,1]
  url = site.to_s
  puts url
  </code></pre>
  
  <p>I get a string like this: </p>
  
  <pre><code>url = &lt;a href="http://en.wikipedia.org/wiki/Gallon" dir="ltr" class="l"&gt;&lt;em&gt;Gallon&lt;/em&gt; - Wikipedia, the free encyclopedia&lt;/a&gt;
  </code></pre>
  
  <p>But I need only the link (http://en.wikipedia.org/wiki/Gallon) not all the html code... 
  How can I do it? I am using the gems: </p>
  
  <pre><code>require 'hpricot'
  require 'open-uri'
  require 'mechanize'
  </code></pre>