我使用WWW :: Mechanize :: Shell来测试东西。perl WWW ::机械化,链接重定向问题
我的代码是这样的:
#!/usr/bin/perl
use WWW::Mechanize;
use HTTP::Cookies;
my $url = "http://mysite/app/login.jsp";
my $username = "username";
my $password = "asdfasdf";
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_number(1);
$mech->field(j_username => $username);
$mech->field(j_password => $password);
$mech->click();
$mech->follow_link(text => "LINK A", n => 1);
$mech->follow_link(text => "LINK B", n => 1);
........................ ......... ............... ........................ 等等
问题是下一个:
LINK B(web_page_b.html),使重定向到web_page_x.html
如果我打印次电子商务mech- $>含量()的内容,显示web_page_b.html
,但我需要显示web_page_x.html,自动提交一个HTML表格(web_page_x.html)
的问题是:
我如何获得web_page_x.html?
感谢
什么样的重定向? Mech会自动跟踪HTTP重定向,除非你不告诉它。如果这是一个Meta标签或Javascript重定向,则需要对其进行反向工程并自行构建等效的HTTP请求。或者使用像Selenium这样基于浏览器的系统。 – friedo 2011-04-29 19:48:47