如何保持WWW :: Mechanize免受以下重定向的影响? [英] How can I keep WWW::Mechanize from following redirects?
问题描述
我有一个Perl脚本,该脚本使用 WWW :: Mechanize 来读取文件并在网站上执行一些自动化任务.但是,每次我请求某个页面后,该网站都会使用302重定向.我不想被重定向(它重定向到的页面需要很长时间才能响应);我只想遍历文件并一遍又一遍地调用第一个链接.我不知道如何使WWW :: Mechanize不遵循重定向.有什么建议吗?
I have a Perl script that uses WWW::Mechanize to read from a file and perform some automated tasks on a website. However, the website uses a 302 redirect after every time I request a certain page. I don't want to be redirected (the page that it redirects to takes too long to respond); I just want to loop through the file and call the first link over and over. I can't figure out how to make WWW::Mechanize NOT follow redirects. Any suggestions?
推荐答案
WWW::Mechanize
是 LWP::UserAgent
的子类.因此,您可以使用任何 LWP::UserAgent
方法.
WWW::Mechanize
is a subclass of LWP::UserAgent
. So you can use any LWP::UserAgent
methods.
my $mech = WWW::Mechanize->new();
$mech->requests_redirectable([]);
这篇关于如何保持WWW :: Mechanize免受以下重定向的影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!