O/H Sudarshan Soma έγραψε:
Thanks a lot. I got the final code now
use warnings;
Since this is a mod_perl list, you might want to consider ``use
strict;'' as well (actually you might consider using strict anyhow)
use HTTP::Cookies;
use HTTP::Request::Common;
use LWP::UserAgent;
{
$ua = new LWP::UserAgent;
if(! $ua) {
print "Can not get the page :UserAgent fialed \n";
return 0;
}
I've never had an LWP::UserAgent fail on me at this step, however...
my $cookies=new HTTP::Cookies(file=>'./cookies.dat',autosave=>1);
$ua->cookie_jar($cookies);
# push does all magic to exrtact cookies and add to header for further
reqs. useragent should be newer
push @{ $ua->requests_redirectable }, 'POST';
$result = $ua->request(POST "http://x.y.z.p",
{
Username =>'xxx',
Password =>'xxx',
Submit =>'Submit'
});
..if really want to check for failures, maybe fold all the rest in an
``if ($result->is_success)'' block.
$resp = $result->content;
$anotherURI = "http://x.y.z.p/gd";
$requestObject = HTTP::Request::Common::GET $anotherURI;
$result = $ua->request($requestObject);
same here
$resp = $result->content;
in all, there are numerous things that might go wrong through the
process (e.g. perhaps you didn't really log in successfully), but maybe
this is a throw-away run once script, so if it works for you...
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscr...@perl.apache.org
For additional commands, e-mail: asp-h...@perl.apache.org