WWW::Mechanize::Pliant - crawl Pliant-based websites
Pliant:
var Str search input "Find:" search button "Go" #...
Or,
var Str search input "Find:" search icon "images/go.png" help "Go" #...
Mechanize code, for both cases:
$mech = WWW::Mechanize::Pliant->new(cookie_jar => {}); $mech->get("http://mypliantsite.com"); $mech->field("search", "Beads Game"); $mech->click("Go");
At the moment, three methods of WWW::Mechanize have been customized for Pliant specific operation: get(), field(), and click(). Instead of string names, they receive regular expressions as arguments.
This is the method that should be used to set the fields in the form.
$form->field('email', 'john@somedomain.com'); $form->field(qr{payment_data.*?card_number}, '4444222233331111'); ... $form->click("Submit Info");
This will click on an image button or on a button. It will try to find the button using these two regular expressions against the content,
try1: qr{title="PATTERN"\s+onClick="button_pressed\('(.*?)'\)"} try2: qr{name="(button.*?)"\s+value="PATTERN"}
The first attempt is to find an image button with PATTERN in the title field. The second attempt is to find a plain button with PATTERN in its caption.
$form->click('Next'); $form->click('Buy now');
Since PATTERN is a regular expression, if the name of the button has parenthesis, you need to escape them:
$form->click(qr{delete Greeting Card \(New Baby\)});
This is a low-level method, that you will not need to use directly.
Context argument is something like "button*0*0..." which is usually an argument to onClick event for image buttons or names of plain buttons. For example, consider this pliant code:
icon "images/next.png" help "Next" ...
To click on it, do this
if ($html =~ m{title="Next"\s+onClick="button_pressed\('(.*?)'\)"}) { $retval = $self->{mech}->pliant_click($1); }
Low-level method. Don't use. Fetches WWW::Mechanize::Pliant::Form object associated with current page.
This helper class does some of the dirty work of locating pliant fields on the pliant page. You shouldn't use it, and its documented here for backward compatibility and completeness.
The Form object works hand in hand with corresponding mechanize object.
This method should be called if the page in the associated mechanize object has changed. It is automatically called at the end of click() routine, so you will most likely never need to call this directly.
Tries to find a field in the form object, given a regex. This doesn't include search over image buttons or standard buttons. If found returns full name of the field (with all the pliant mangling), or undef if not found.
See WWW::Mechanize::Pliant::field(), usage is the same.
See WWW::Mechanize::Pliant::click(), usage is the same.
Boris Reitman <boris.reitman@gmail.com>
WWW::Mechanize, http://en.wikipedia.org/wiki/Pliant
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install WWW::Mechanize::Pliant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Mechanize::Pliant
CPAN shell
perl -MCPAN -e shell install WWW::Mechanize::Pliant
For more information on module installation, please visit the detailed CPAN module installation guide.