我正在尝试从网站下载xls文件 http://www.ncdex.com/MarketDataAction_bhavCopy.action
使用Mechanize模块点击方法, 但它给出了如下错误:
错误发布http://www.ncdex.com/MarketDataAction_bhavCopySubmit.action:在click_method.pl第6行找不到。
这是我的代码:
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
my $url = 'http://www.ncdex.com/MarketDataAction_bhavCopy.action';
$mech->get( $url );
$mech->submit_form(
fields => {
'dateSelected' => '13/03/2017',
}
);
$mech->click_button(
name => "buttonType",
id => "buttonType",
value => "xls Format",
type => "submit"
);
print $mech->content();
我想从本网站下载xls文件,日期为13/03/2017或任何其他日期
答案 0 :(得分:0)
直接点击如下所示的网址并将数据写入.xls文件
use WWW::Mechanize;
my $mech = WWW::Mechanize->new(autocheck => 0);
$mech->get("http://www.ncdex.com/MarketDataAction_bhavCopySubmit.action?bhavTitle=bhav&dateSelected=13%2F03%2F2017&buttonType=xls+Format");
my $data = $mech->content;
print $data;
您可以通过运行代码并将输出重定向到.xls文件来检查代码 例如: - perl test.pl> output.xls