Retrieve redirect URLs from an URL

For a project I am currently working on I am looking for a solution that
gives me an ordened list of all the URLs that are in a redirect chain.

Lets say I have an URL x, clicking this in a normal browser would
redirect to y, which would redirect me to z; my final destination.

Having just URL x, how can I get URL y and z? Do I need to use cURL to
extract the heads recursively from all urls until there are no more
redirects? How would I go about doing this?

Thanks.

Anyone got any advice on this situation?

Tom Pett wrote:

Anyone got any advice on this situation?


dude,

do u require to perform any operation btw each redirect??

Reply…

I have found the gem HTTParty which is supposed to help me with this
task.

I am having some troubles getting this to work on my environment.
Currently I run Rails 2.3.5, HTTParty 0.5.2 on Windows Vista (developer
machine).

I would really appreciate it if someone could give me an example code
snippit on how I should do this.

Again, imagine the following: URL A redirect to URL B. B redirects to C.
C is a normal website that can be retrieved via GET.

By supplying A, I want an array in return containing [A,B,C]

Rutvij P. wrote:

Tom Pett wrote:

Anyone got any advice on this situation?


dude,

do u require to perform any operation btw each redirect??

Reply…

Not really. I would just like a list of (chain) redirects to write in a
database. I just want to extra all redirect information from an URL at
any given time. Nothing has to be computed real time or during the
redirects for my application.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs