Forum: Ruby mechanize error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
64a30f3037e399104d89d9ae1dddc6d4?d=identicon&s=25 Dor Kalev (Guest)
on 2006-05-18 17:31
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'
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-05-18 17:40
(Received via mailing list)
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?
64a30f3037e399104d89d9ae1dddc6d4?d=identicon&s=25 Dor Kalev (Guest)
on 2006-05-18 17:53
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?
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-05-18 19:17
(Received via mailing list)
On 5/18/06, Dor Kalev <dor@octava.co.il> 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?
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-05-18 21:12
(Received via mailing list)
Dor Kalev 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 Britt

"A language that doesn't affect the way you think about programming is
not worth knowing."
   - A. Perlis
This topic is locked and can not be replied to.