From: Tom Stone Date: 2002-10-31T06:18:35+09:00 Subject: Re: get index.htm and read it out Could it be the failure that i'm using this version? ruby 1.7.2 (2002-07-02) [i386-mswin32] "Bill Kelly" wrote in message news:023001c28050$003ea640$fa7b1b42@musicbox... > Hi, > > From: "Tom Stone" > > Hi, > > I found this code the pragmatic programmers book. > > require 'net/http' > > > > h = Net::HTTP.new('www.pragmaticprogrammer.com', 80) > > resp, data = h.get('http://www.pragmaticprogrammer.com/index.html', nil) > > if resp.message == "OK" > > data.scan(/ > end > > > > So I copied this code and tried to execute it with the ruby interpreter. But > > it didn't work. It just displays an errror message "private method scan > > called for nil". Does anyone have a suggestion why this does not work? > > Thanks > > Pasting lines from your email above into irb worked OK for me > here (ruby 1.6.6 (2001-12-26) [i586-mswin32]). > > irb> require 'net/http' > true > irb> h = Net::HTTP.new('www.pragmaticprogrammer.com', 80) > # > irb> resp, data = h.get('http://www.pragmaticprogrammer.com/index.html', nil) > [#, " HTML 4.0 Transitional//EN\"> [......long string elided.....] > irb> resp.message == "OK" > true > irb> data.scan(/ images/title_main.gif > images/dot.gif > images/dot.gif > images/dot.gif > images/aafounders_70.jpg > images/pp_cover_thumb.png > images/ruby_cover_thumb.png > images/dot.gif > images/dot.gif > > > Perhaps if you try it in IRB it'll be more clear which part > of the code is failing on your system? > > HTH, > > Bill > > > > >