Mechanize error

hi,
it seems Mechanize isn’t working well with relative URLs -

the following lines:

agent = WWW::Mechanize.new { |a| a.log = Logger.new(“mech.log”) }
article = agent.get(’/test.html’)

responded with the following error:

c:/instantrails/ruby/lib/ruby/gems/1.8/gems/mechanize-0.4.3/lib/mechanize.rb:183:in
to_absolute_uri' c:/instantrails/ruby/lib/ruby/gems/1.8/gems/mechanize-0.4.3/lib/mechanize.rb:114:inget’

Dor K. wrote:

c:/instantrails/ruby/lib/ruby/gems/1.8/gems/mechanize-0.4.3/lib/mechanize.rb:183:in
to_absolute_uri' c:/instantrails/ruby/lib/ruby/gems/1.8/gems/mechanize-0.4.3/lib/mechanize.rb:114:inget’

Where have you told it what host to look at?

Alex Y. wrote:

Dor K. wrote:

c:/instantrails/ruby/lib/ruby/gems/1.8/gems/mechanize-0.4.3/lib/mechanize.rb:183:in
to_absolute_uri' c:/instantrails/ruby/lib/ruby/gems/1.8/gems/mechanize-0.4.3/lib/mechanize.rb:114:inget’

Where have you told it what host to look at?

well, i didn’t, where should I?

On 5/18/06, Dor K. [email protected] wrote:


Posted via http://www.ruby-forum.com/.

agent.get(‘http://google.com’)
#=> #<WWW::Page:0x2de2ae8 …

agent.get(‘/reader’)
#=> #<WWW::Page:0x2de2ae8 …

Otherwise, how would agnet know which host to get ‘/test.html’ from?

Dor K. wrote:

Where have you told it what host to look at?

well, i didn’t, where should I?

You can see a Mechanize example here:


James B.

“A language that doesn’t affect the way you think about programming is
not worth knowing.”

  • A. Perlis