Get final URL after curl is redirected

前端 未结 11 1936
清酒与你
清酒与你 2020-12-04 07:38

I need to get the final URL after a page redirect preferably with curl or wget.

For example http://google.com may redirect to http://www.google.com

11条回答
  •  一整个雨季
    2020-12-04 07:53

    I'm not sure how to do it with curl, but libwww-perl installs the GET alias.

    $ GET -S -d -e http://google.com
    GET http://google.com --> 301 Moved Permanently
    GET http://www.google.com/ --> 302 Found
    GET http://www.google.ca/ --> 200 OK
    Cache-Control: private, max-age=0
    Connection: close
    Date: Sat, 19 Jun 2010 04:11:01 GMT
    Server: gws
    Content-Type: text/html; charset=ISO-8859-1
    Expires: -1
    Client-Date: Sat, 19 Jun 2010 04:11:01 GMT
    Client-Peer: 74.125.155.105:80
    Client-Response-Num: 1
    Set-Cookie: PREF=ID=a1925ca9f8af11b9:TM=1276920661:LM=1276920661:S=ULFrHqOiFDDzDVFB; expires=Mon, 18-Jun-2012 04:11:01 GMT; path=/; domain=.google.ca
    Title: Google
    X-XSS-Protection: 1; mode=block
    

提交回复
热议问题