ABSTRACT
WWW::Mechanize::Pliant - crawl Pliant-based websites
SYNOPSIS
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");
DETAILS
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.
- field(pattern, value)
-
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");
- click(PATTERN)
-
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\)});
LOW LEVEL METHODS
- pliant_click(context)
-
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); }
- pliant_form()
-
Low-level method. Don't use. Fetches WWW::Mechanize::Pliant::Form object associated with current page.
WWW::Mechanize::Pliant::Form
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.
- new(mech)
-
The Form object works hand in hand with corresponding mechanize object.
- reinit()
-
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.
- find_field(pattern)
-
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.
- set_field(pattern, value)
-
See WWW::Mechanize::Pliant::field(), usage is the same.
- click(PATTERN)
-
See WWW::Mechanize::Pliant::click(), usage is the same.
AUTHOR
Boris Reitman <boris.reitman@gmail.com>
SEE ALSO
WWW::Mechanize, http://en.wikipedia.org/wiki/Pliant
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 365:
You forgot a '=back' before '=head1'