Nokogiri & Rb 1.9.2-p0

Is there an error with nokogiri and title recent windows build of ruby
1.9.2-p0?

I have installed ruby and nokogiri gem. I was following the railscast
http://railscasts.com/episodes/190-screen-scraping-with-nokogiri

As I am just learning things I thought I would start by running the
script from the tutorial.

To change this template, choose Tools | Templates

and open the template in the editor.

To change this template, choose Tools | Templates

and open the template in the editor.

nokogiri_test.rb

require ‘rubygems’
require ‘nokogiri’
require ‘open-uri’

url = “http://www.walmart.com/search/search-ng.do?
search_constraint=0&ic=48_0&search_query=batman&Find.x=0&Find.y=0&Find=Find”
doc = Nokogiri::HTML(open(url))
puts doc.at_css(“title”).text
doc.css(".item").each do |item|
title = item.at_css(".prodLink").text
price = item.at_css(".PriceCompare .BodyS, .PriceXLBold").text[/
$[0-9.]+/]
puts “#{title} - #{price}”
puts item.at_css(".prodLink")[:href]
end

lib/tasks/product_prices.rake

desc “Fetch product prices”
task :fetch_prices => :environment do
require ‘nokogiri’
require ‘open-uri’

Product.find_all_by_price(nil).each do |product|
url = “http://www.walmart.com/search/search-ng.do?
search_constraint=0&ic=48_0&search_query=#{CGI.escape(product.name)}
&Find.x=0&Find.y=0&Find=Find”
doc = Nokogiri::HTML(open(url))
price = doc.at_css(".PriceCompare .BodyS, .PriceXLBold").text[/
[0-9.]+/]
product.update_attribute(:price, price)
end
end

I keep getting this error.

Walmart.com: Search Results for “batman”
C:/Documents and Settings/Family/My Documents/NetBeansProjects/
RubyApplication3/lib/main.rb:17:in block in <main>': undefined methodtext’ for nil:NilClass (NoMethodError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86-
mingw32/lib/nokogiri/xml/node_set.rb:239:in block in each' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86- mingw32/lib/nokogiri/xml/node_set.rb:238:inupto’
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86-
mingw32/lib/nokogiri/xml/node_set.rb:238:in each' from C:/Documents and Settings/Family/My Documents/ NetBeansProjects/RubyApplication3/lib/main.rb:15:in

similar error from scite

ruby myrubyNoki.rb
myrubyNoki.rb:17:in block in <main>': undefined methodtext’ for
nil:NilClass (NoMethodError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86-mingw32/
lib/nokogiri/xml/node_set.rb:239:in block in each' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86-mingw32/ lib/nokogiri/xml/node_set.rb:238:inupto’
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86-mingw32/
lib/nokogiri/xml/node_set.rb:238:in each' from myrubyNoki.rb:15:in
Walmart.com: Search Results for “batman”

On Oct 15, 12:36am, flebber [email protected] wrote:

doc = Nokogiri::HTML(open(url))
desc “Fetch product prices”
[0-9.]+/]
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86-

ruby myrubyNoki.rb
Walmart.com: Search Results for “batman”

Exit code: 1

Nobody else having issues with this? Any easy way to fix. I have
updated gems and made sure all dependencies are covered but no go.
Should I go back to 1.9.1 or 1.8.9 ro get compatibility?

On Oct 14, 2010, at 06:40 , flebber wrote:

Is there an error with nokogiri and title recent windows build of ruby
1.9.2-p0?

You’d be much better off bringing this up on the nokogiri mailing list
or filing a ticket in their issue tracker. This mailing list is not good
for specific third party library technical support.

On Oct 15, 10:55am, Ryan D. [email protected] wrote:

On Oct 14, 2010, at 06:40 , flebber wrote:

Is there an error with nokogiri and title recent windows build of ruby
1.9.2-p0?

You’d be much better off bringing this up on the nokogiri mailing list or filing
a ticket in their issue tracker. This mailing list is not good for specific third
party library technical support.

Ah okay because I went back to ruby 1.9.1 and still get same output
error.

ruby nokogiritest.rb
nokogiritest.rb:11:in block in <main>': undefined methodtext’ for
nil:NilClass (NoMethodError)
from C:/Ruby191/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/
nokogiri/xml/node_set.rb:239:in block in each' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/ nokogiri/xml/node_set.rb:238:inupto’
from C:/Ruby191/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1/lib/
nokogiri/xml/node_set.rb:238:in each' from nokogiritest.rb:9:in
Walmart.com: Search Results for “batman”

On Oct 15, 11:51am, flebber [email protected] wrote:

error.
nokogiri/xml/node_set.rb:238:in each' from nokogiritest.rb:9:in
Walmart.com: Search Results for “batman”

Exit code: 1

Actually I have tested on 1.9.2, 1.9.1 & 1.8.7 and didn’t work with
railscast script. Must be something I am doing this end, Newbie error.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs