LeoCoder has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks - I am trying to retrieve the table data from this page http://bogc.dnrc.mt.gov/WebApps/DataMiner/Wells/WellCompletions.aspx using mechanize. I am not able to get the result page after post. I am passing all parameters with the form. But it is not working. Please assists me to solve this invisible bug. :)
use strict; use warnings; use LWP::Simple; use WWW::Mechanize; #Access to the root page my $agent; $agent = WWW::Mechanize->new(); my $rootpage = "http://bogc.dnrc.mt.gov/WebApps/DataMiner/Wells/We +llCompletions.aspx"; #Get the root page $agent->get($rootpage); #Get Form data $agent->form_name('aspnetForm'); my $eventtarget = $agent->field('__EVENTTARGET'); my $eventarg = $agent->field('__EVENTARGUMENT'); my $lastfocus = $agent->field('__LASTFOCUS'); my $viewstate = $agent->field('__VIEWSTATE'); my $viewstategen = $agent->field('__VIEWSTATEGENERATOR'); my $eventValidation = $agent->field('__EVENTVALIDATION'); #Construct fields my $fields = { 'ctl00$ScriptManager1' => 'ctl00$SiteContentPlaceHolder$FormFi +lterNoNav1$UpdatePanelFormFilterNoNav|ctl00$SiteContentPlaceHolder$Fo +rmFilterNoNav1$btnSearch', '__EVENTTARGET' => $eventtarget, '__EVENTARGUMENT' => $eventarg, '__LASTFOCUS' => $lastfocus, '__VIEWSTATE' => $viewstate, '__VIEWSTATEGENERATOR' => $viewstategen, '__EVENTVALIDATION' => $eventValidation, 'ctl00$SiteContentPlaceHolder$FormFilterNoNav1$cboFilterOption +' => 'Dt_Effect|date', 'ctl00$SiteContentPlaceHolder$FormFilterNoNav1$cboFilterType' +=> '<', 'ctl00$SiteContentPlaceHolder$FormFilterNoNav1$txtFilter' => ' +09/06/2016', 'ctl00$SiteContentPlaceHolder$FormFilterNoNav1$txtFilterString +' => '', 'ctl00$SiteContentPlaceHolder$FormFilterNoNav1$btnSearch' => ' +Search' }; #Submit request to get data. $result = $agent->submit_form( form_name => 'aspnetForm', fields => $fields, ); $agent->save_content("C:/" . "Completions.html");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ASPX Form Post
by choroba (Cardinal) on Sep 08, 2016 at 14:46 UTC | |
by LeoCoder (Initiate) on Sep 08, 2016 at 14:52 UTC | |
by Corion (Patriarch) on Sep 08, 2016 at 18:42 UTC | |
by LeoCoder (Initiate) on Sep 08, 2016 at 20:26 UTC | |
by LeoCoder (Initiate) on Sep 08, 2016 at 20:43 UTC | |
|
Re: ASPX Form Post
by hippo (Archbishop) on Sep 08, 2016 at 18:33 UTC | |
by LeoCoder (Initiate) on Sep 08, 2016 at 20:55 UTC | |
by hippo (Archbishop) on Sep 09, 2016 at 08:20 UTC | |
by Anonymous Monk on Jun 21, 2018 at 18:01 UTC |