Perhaps the page you are retrieving is compressed. Try out this code , i haven't checked it as i don't have internet access, but i hope it works.
use strict;
use warnings;
use Compress::Zlib;
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
# Initialize a new oblect
my $mech = WWW::Mechanize->new();
# Fetch the given URL
my $url = "https://secure.secret.com/login/login.cfm?someParam=foo";
$mech->get($url);
# Throw error if page not found
$mech->success or die "Can't fetch the Requested page";
# Uncompress the page
my $dest = Compress::Zlib::memGunzip($mech->content);
# Initialize a new object to retrieve the form
my $f = WWW::Mechanize::FormFiller->new();
my $form = HTML::Form->parse($dest,$mech->base);
# Fill the form with login & password and submit
$f->fillout(user=>'xxx',password=>'xxx');
$f->fill_form($form);
my $request = $form->click();
# Fetch the next page
$mech->request($request);
# Uncompress the page
$dest = Compress::Zlib::memGunzip($mech->content);
# Retrieve the form & check for string
$form = HTML::Form->parse($dest,$mech->base);
print "$form\n";
exit 0;
I hope this works.
Neeraj.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|