简体   繁体   中英

Testing for redirects in Perl

I was hoping to check for webpage redirects using Perl. I've tried using LWP but it only catches 503 redirects and not htaccess redirects or Javascript redirects. Any help would be greatly appreciated.

Thanks

LWP defaults to processing 3xx redirects (I think you are calling these htaccess redirects) for GET and HEAD, but you can modify this by setting the requests_redirectable option, or by subclassing LWP and catching the requests_ok callback, or by calling simple_request instead of request.

For javascript redirects, you will need to handle javascript; I'm not sure what the current best means of this is, but there are ways to do it.

You probably also want to check for meta tag refresh redirects.

Or take a look at WWW::Mechanize and Test::WWW::Mechanize . You can say for example to follow some link or to click some button. Then you can just simply check if the response status code matches qr/3\\d\\d/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM