title: Difficulty screen scraping http://www.momondo.com using nokogiri
body: <p>I have some difficulty to extract the total price (css selector = '.total') from the flight result.</p>
  
  <pre><code>http://www.momondo.com/multicity/?Search=true&amp;TripType=oneway&amp;SegNo=1&amp;SO0=KUL&amp;SD0=KBR&amp;SDP0=31-12-2012&amp;AD=2&amp;CA=0,0&amp;DO=false&amp;NA=false#Search=true&amp;TripType=oneway&amp;SegNo=1&amp;SO0=KUL&amp;SD0=KBR&amp;SDP0=31-12-2012&amp;AD=2&amp;CA=0,0&amp;DO=false&amp;NA=false
  </code></pre>
  
  <p>I get the error "undefined method `text' for nil:NilClass nokogiri ".</p>
  
  <p>My code</p>
  
  <pre><code>desc "Fetch product prices"
  task :fetch_details =&gt; :environment do
    require 'nokogiri'
    require 'open-uri'
    include ERB::Util
  
    OneWayFlight.find_all_by_money(nil).each do |flight|
      url = "http://www.momondo.com/multicity/Search=true&amp;TripType=oneway&amp;SegNo=1&amp;SO0=KUL&amp;SD0=KBR&amp;SDP0=31-12-2012&amp;AD=2&amp;CA=0,0&amp;DO=false&amp;NA=false#Search=true&amp;TripType=oneway&amp;SegNo=1&amp;SO0=KUL&amp;SD0=KBR&amp;SDP0=31-12-2012&amp;AD=2&amp;CA=0,0&amp;DO=false&amp;NA=false"
      doc = Nokogiri::HTML(open(url))
      price = doc.at_css(".total").text[/[0-9\.]+/]
      flight.update_attribute(:price, price)
    end
  end
  </code></pre>