Mechanize error


#1

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’


#2

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?


#3

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?


#4

On 5/18/06, Dor K. removed_email_address@domain.invalid 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?


#5

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:

http://neurogami.com/cafe-fetcher/


James B.

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

  • A. Perlis