开发者

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 redirect开发者_如何转开发s. 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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜