.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "WWW::Mechanize::FormFiller 3pm" .TH WWW::Mechanize::FormFiller 3pm "2022-08-20" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" WWW::Mechanize::FormFiller \- framework to automate HTML forms .SH "SYNOPSIS" .IX Header "SYNOPSIS" Form fields can be specified by name or by a regular expression. A field specified by name takes precedence over a matching regular expression. .PP You are not limited to fixed form values \- callbacks and interactive editing are also already provided : .PP .Vb 1 \& # Create a form filler that asks us for the password \& \& # Normally, the HTML would come from a LWP::UserAgent request \& my $html = "
"; \& \& my $f = WWW::Mechanize::FormFiller\->new(); \& my $form = HTML::Form\->parse($html,"http://www.fbi.gov/super/secret/"); \& \& $f\->add_filler( password => Interactive => []); \& $f\->fill_form($form); \& \& my $request = $form\->click("Login"); \& \& # Now we have a complete HTTP request, which we can hand off to \& # LWP::UserAgent or (preferrably) WWW::Mechanize \& print $request\->as_string; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The module is intended as a simple way to fill out \s-1HTML\s0 forms from a set of predetermined values. You set up the form filler with value elements, retrieve the \s-1HTML\s0 form, and let the form filler loose on that form. .PP There are value classes provided for many tasks \- fixed values, values to be queried interactively from the user, values taken randomly from a list of values and values specified through a callback to some Perl code. .ie n .IP "new %ARGS" 4 .el .IP "new \f(CW%ARGS\fR" 4 .IX Item "new %ARGS" Creates a new instance. The \f(CW%ARGS\fR hash has two possible keys : \&\f(CW\*(C`default\*(C'\fR, whose value should be an array reference consisting of the name of a \f(CW\*(C`WWW::Mechanize::FormFiller::Value\*(C'\fR subclass and the optional constructor values. \&\f(CW\*(C`values\*(C'\fR must be an array reference, which contains array and \f(CW\*(C`Files\*(C'\fR, which takes an array reference to the filenames to watch. .Sp Example : .ie n .IP "add_filler \s-1NAME, CLASS,\s0 @ARGS" 4 .el .IP "add_filler \s-1NAME, CLASS,\s0 \f(CW@ARGS\fR" 4 .IX Item "add_filler NAME, CLASS, @ARGS" Adds a new value to the list of filled fields. \f(CW\*(C`NAME\*(C'\fR is the name of the form field, \f(CW\*(C`CLASS\*(C'\fR is the name of the class in the \&\f(CW\*(C`WWW::Mechanize::FormFiller::Value\*(C'\fR namespace \- it must live below there ! \f(CW@ARGS\fR is an optional array reference to the parameters that the subclass constructor takes. .IP "add_value \s-1NAME, VALUE\s0" 4 .IX Item "add_value NAME, VALUE" Adds a new WWW::Mechanize::FormFiller::Value subclass to the list of filled fields. \f(CW\*(C`NAME\*(C'\fR is the name of the form field, \f(CW\*(C`VALUE\*(C'\fR is an object that responds to the interface of \f(CW\*(C`WWW::Mechanize::FormFiller::Value\*(C'\fR. .IP "fill_form \s-1FORM\s0" 4 .IX Item "fill_form FORM" Sets the field values in \s-1FORM\s0 to the values returned by the \&\f(CW\*(C`WWW::Mechanize::FormFiller::Value\*(C'\fR elements. \s-1FORM\s0 should be of type HTML::Forms or respond to the same interface. .ie n .IP "fillout @ARGS" 4 .el .IP "fillout \f(CW@ARGS\fR" 4 .IX Item "fillout @ARGS" This is a very dwimmy routine that allows you to intuitively set up values and fill out a form, if needed. It works as both a constructor and a method. The parameters are decoded according to the following examples : .Sp .Vb 4 \& $filler = WWW::Mechanize::FormFiller\->new(); \& $filler\->fillout( \& # For the the simple case, assumed \*(AqFixed\*(Aq class, \& name => \*(AqMark\*(Aq, \& \& # With an array reference, create and fill with the right kind of object. \& widget_id => [ \*(AqRandom\*(Aq, (1..5) ], \& ); .Ve .Sp .Vb 8 \& $filler = WWW::Mechanize::FormFiller\->new(); \& $filler\->fillout( \& # If the first parameter isa HTML::Form, it is \& # filled out directly \& $form, \& name => \*(AqMark\*(Aq, \& motto => [ \*(AqRandom::Word\*(Aq, size => 5 ], \& ); .Ve .Sp .Vb 6 \& # This works as a direct constructor as well \& WWW::Mechanize::FormFiller\->fillout( \& $form2, \& name => \*(AqMark\*(Aq, \& motto => [ \*(AqRandom::Word\*(Aq, size => 5 ], \& ); .Ve .SS "Value subclasses" .IX Subsection "Value subclasses" The following WWW::Mechanize::FormFiller::Value subclasses are currently distributed : .IP "WWW::Mechanize::FormFiller::Value::Callback" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Callback" .PD 0 .IP "WWW::Mechanize::FormFiller::Value::Default" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Default" .IP "WWW::Mechanize::FormFiller::Value::Fixed" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Fixed" .IP "WWW::Mechanize::FormFiller::Value::Interactive" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Interactive" .IP "WWW::Mechanize::FormFiller::Value::Keep" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Keep" .IP "WWW::Mechanize::FormFiller::Value::Random" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Random" .IP "WWW::Mechanize::FormFiller::Value::Random::Word" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Random::Word" .IP "WWW::Mechanize::FormFiller::Value::Random::Chars" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Random::Chars" .IP "WWW::Mechanize::FormFiller::Value::Random::Date" 4 .IX Item "WWW::Mechanize::FormFiller::Value::Random::Date" .PD .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" None by default. .SS "\s-1COPYRIGHT AND LICENSE\s0" .IX Subsection "COPYRIGHT AND LICENSE" This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP Copyright (C) 2002,2003 Max Maischein .SH "AUTHOR" .IX Header "AUTHOR" Max Maischein,