GET doesnt seem to work in this case

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

MKSM> wrote:
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...

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 Britt

“Design depends largely on constraints.”
  — Charles Eames