# Nokogiri & Rb 1.9.2-p0

**URL:** <https://www.ruby-forum.com/t/nokogiri-rb-1-9-2-p0/197446>\
**Category:** Ruby\
**Created:** [October 14, 2010, 3:40pm UTC](https://www.ruby-forum.com/t/nokogiri-rb-1-9-2-p0/197446 "2010-10-14T15:40:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 14, 2010, 3:40pm UTC](https://www.ruby-forum.com/t/nokogiri-rb-1-9-2-p0/197446/1 "2010-10-14T15:40:34Z")

</div>

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

> **[\#190 Screen Scraping with Nokogiri - RailsCasts](http://railscasts.com/episodes/190-screen-scraping-with-nokogiri)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

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](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](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](http://Walmart.com): Search Results for “batman”  
C:/Documents and Settings/Family/My Documents/NetBeansProjects/  
RubyApplication3/lib/main.rb:17:in `block in <main>': undefined method `text’ 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:in `upto’  
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 method `text’ 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:in `upto’  
> 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](http://Walmart.com): Search Results for “batman”

---

<div class="post-metadata">

**Author:** ![flebber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f9ae1b/32.png) [@flebber](https://www.ruby-forum.com/u/flebber)\
**Post date:** [October 15, 2010, 12:50am UTC](https://www.ruby-forum.com/t/nokogiri-rb-1-9-2-p0/197446/2 "2010-10-15T00:50:51Z")

</div>

On Oct 15, 12:36am, flebber [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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?

---

<div class="post-metadata">

**Author:** ![flebber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f9ae1b/32.png) [@flebber](https://www.ruby-forum.com/u/flebber)\
**Post date:** [October 15, 2010, 1:56am UTC](https://www.ruby-forum.com/t/nokogiri-rb-1-9-2-p0/197446/3 "2010-10-15T01:56:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![flebber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f9ae1b/32.png) [@flebber](https://www.ruby-forum.com/u/flebber)\
**Post date:** [October 15, 2010, 2:57am UTC](https://www.ruby-forum.com/t/nokogiri-rb-1-9-2-p0/197446/4 "2010-10-15T02:57:40Z")

</div>

On Oct 15, 10:55am, Ryan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 method `text’ 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:in `upto’  
> 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](http://Walmart.com): Search Results for “batman”

---

<div class="post-metadata">

**Author:** ![flebber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f9ae1b/32.png) [@flebber](https://www.ruby-forum.com/u/flebber)\
**Post date:** [October 15, 2010, 4:10am UTC](https://www.ruby-forum.com/t/nokogiri-rb-1-9-2-p0/197446/5 "2010-10-15T04:10:42Z")

</div>

On Oct 15, 11:51am, flebber [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> error.  
> nokogiri/xml/node\_set.rb:238:in `each' from nokogiritest.rb:9:in `’  
> [Walmart.com](http://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.
