Forum: Ruby GET doesnt seem to work in this case.

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.
|MKSM| (Guest)
on 2006-04-14 21:51
(Received via mailing list)
Hello,

I'm trying to grab some info off www.yellowbook.com for a specific city.

While testing a simple program to just grab the index page i couldnt
manage to get it working. Here's what i have so far.

http = Net::HTTP.new('www.yellowbook.com', 80)
res = http.send_request('GET', '/')
p res.body

I get a object moved page all the time. I tested it with my browser
and it works perfectly. Could anyone kindly point what im doing wrong
here? Perhaps this method is not appropriate for this  task...

Thanks,

Ricardo Amorim
James B. (Guest)
on 2006-04-14 22:00
(Received via mailing list)
|MKSM| wrote:
>
> I get a object moved page all the time. I tested it with my browser
> and it works perfectly. Could anyone kindly point what im doing wrong
> here? Perhaps this method is not appropriate for this  task...

I think your browser is automatically handling the "object moved"
response and issuing a second request to the new URL.

Your client code will either have to parse the response and make a new
request if it gets a "moved" response, or you can just use that new URL
as the the starting point.


--
James B.

?Design depends largely on constraints.?
  ? Charles Eames
This topic is locked and can not be replied to.