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:in
`get'

···

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

Dor Kalev wrote:

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:in `get'

Where have you told it what host to look at?

···

--
Alex

Alex Young wrote:

Dor Kalev 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:in
`get'

Where have you told it what host to look at?

well, i didn't, where should I?

···

--
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?

···

On 5/18/06, Dor Kalev <dor@octava.co.il> wrote:

Alex Young wrote:
> Dor Kalev 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:in
>> `get'
>>
> Where have you told it what host to look at?

well, i didn't, where should I?

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

--
-Alder

Dor Kalev wrote:

Alex Young wrote:

Dor Kalev 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:in `get'

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 Britt

"A language that doesn't affect the way you think about programming is not worth knowing."
   - A. Perlis