cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: getting the final redirected url...

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Tue, 24 May 2011 14:49:16 -0400

On Tue, May 24, 2011 at 1:13 PM, srinivasan r <sri_sssitc_at_yahoo.co.in>wrote:

> Given an ip address/domain name, I wish to get the final URL where the
> browser would land, after all the redirects that may happen to the
> address/domain name.
>
> For example, if I had typed "bru01s01-in-f103.1e100.net" in the browser,
> it would have led me to "http://www.google.co.in/". I would like to have
> this Google URL as the result of a Curl command.
>
> Well, I could type it in the browser, but that's not what I want.
> Eventually, I am looking for this action, to find the final redirected URL
> for a long list of ip addresses. If I can get curl do this for a single one,
> I can work out how to do it for a list.
>
> How to accomplish this with Curl ?
>
> I know I might be being shameless here, but I request if someone can write
> a sample line of command to do just the above. Instead of just mentioning
> what parameters to be try out and how ? I have tried some -e, -I, -L etc,
> and doesn't seem to get it right. Not a commandpromptuous guy :).
>
> I am running curl from the windows command prompt on Windows XP
> Professional as Administrator. No problems running curl, and the sample
> command "curl http://curl.haxx.se" works just fine.

     curl -w "%{url_effective}\n" -L -s -S -o out.html
http://bru01s01-in-f103.1e100.net

Ralph Mitchell

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-24