How can I find the final URL after all redirections in Perl?

前端 未结 2 1342
说谎
说谎 2021-01-18 21:19

Lets say I have \"http://www.ritzcarlton.com\" and that redirects me to \"http://www.ritzcarlton.com/en/Default.htm\". Is there a way in Perl to find the end url after all t

2条回答
  •  轮回少年
    2021-01-18 21:42

    If you're issuing HTTP requests yourself, then the redirect URL will be in the returned Location: header. If you're using a proper HTTP client like LWP::UserAgent or WWW::Mechanize, which is what you should be doing, redirection is handled automatically.

提交回复
热议问题