I am trying to download xls file from website http://www.ncdex.com/MarketDataAction_bhavCopy.action
using Mechanize module click method, but it gives error like :
Error POSTing http://www.ncdex.com/MarketDataAction_bhavCopySubmit.action: Not Found at click_method.pl line 6.
Here is my code:
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();
I want to download xls file from this website for date 13/03/2017 or any other date
Directly hit the url as below and write data to a .xls file
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;
You can check the code by running it and redirecting output to .xls file Eg:- perl test.pl > output.xls