| jingjing.zhu@gmail.com 2005-08-31, 6:55 pm |
| Hi,
I was trying to program in Perl to send a POST request to a web
server. The client HTML form is like:
<form name="Form1" method="post" action="report.aspx" id="Form1">
<input type="hidden" name="__EVENTTARGET" value=""/>
<input type="hidden" name="__EVENTTARGUMENT" value=""/>
.....
And I wrote the following Perl script to fill out the __EVENTTARGET
value,
my $ua = LWP::UserAgent->new;
push @ { $ua->requests_redirectable }, 'POST';
$ua->cookie_jar( HTTP::Cookies->new(autosave=>1));
$ua->agent("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; FunWebProducts")
#....
# Loging process
# a Get request sent to get the form and set cookies in user agent
#.....
$rs = $ua->post( 'https://www.xxxx.com/report.aspx',
[
__EVENTTARGET => 'reports:_ctl3:lnkReport'
],
'Content-Type' =>'application/x-www-form-urlencoded',
'CACHE-CONTROL' =>'NO-CACHE',
':content_file' => 'temp.html');
I expect to get a webpage with report data. Unfortunately, the
webserver returns 200 ok status code but the result page is the same as
the form.
Could anyone see any errors in my script?
Thanks very much,
Jing
|