MAN page from Old RedHat 6.X perl-libwww-perl-5.47-6.i386.rpm
lib::HTML::Form
Section: User Contributed Perl Documentation (3)
Updated: libwww-perl-5.47
Index NAME
HTML::Form - Class that represents HTML forms
SYNOPSIS
use HTML::Form; $form = HTML::Form->parse($html, $base_uri); $form->value(query => "Perl");
use LWP; LWP::UserAgent->new->request($form->click);
DESCRIPTION
Objects of the
HTML::Form class represents a single HTML <form>... </form> instance. A form consist of a sequence of inputs thatusually have names, and which can take on various values.
The following methods are available:
- $form = HTML::Form->new($method, $action_uri, [[$enctype], $input,...])
- The constructor takes a $method and a $uri as argument. The $enctypeand and initial inputs are optional. You will normally useHTML::Form->parse() to create new HTML::Form objects.
- @forms = HTML::Form->parse($html_document, $base_uri)
- The parse() class method will parse an HTML document and build upHTML::Form objects for each <form> found. If called in scalarcontext only returns the first <form>. Returns an empty list if thereare no forms to be found.
The $base_uri is (usually) the URI used to access the $html_document.It is needed to resolve relative action URIs. For LWP this parameteris obtained from the $response->base() method.
- $form->push_input($type, \%attr)
- Adds a new input to the form.
- $form->method( [$new] )
- $form->action( [$new] )
- $form->enctype( [$new] )
- These method can be used to get/set the corresponding attribute of theform.
- $form->inputs
- This method returns the list of inputs in the form.
- $form->find_input($name, $type, $no)
- This method is used to locate some specific input within the form. Atleast one of the arguments must be defined. If no matching input isfound, undef is returned.
If $name is specified, then the input must have the indicated name.If $type is specified then the input must have the specified type. Inaddition to the types possible for <input> HTML tags, we also have``textarea'' and ``option''. The $no is the sequence number of the inputwith the indicated $name and/or $type (where 1 is the first).
- $form->value($name, [$value])
- The value() method can be used to get/set the value of some input. Ifno input have the indicated name, then this method will croak.
- $form->try_others(\&callback)
- This method will iterate over all permutations of unvisited enumeratedvalues (<select>, <radio>, <checkbox>) and invoke the callback foreach. The callback is passed the $form as argument.
- $form->make_request
- Will return a HTTP::Request object that reflects the current settingof the form. You might want to use the click method instead.
- $form->click([$name], [$x, $y])
- Will click on the first clickable input (input/submit orinput/image), with the indicated $name, if specified. You canoptinally specify a coordinate clicked, which only makes a differenceif you clicked on an image. The default coordinate is (1,1).
- $form->form
- Returns the current setting as a sequence of key/value pairs.
- $form->dump
- Returns a textual representation of the form. Mainly useful fordebugging. If called in void context, then the dump is printed onSTDERR.
INPUTS
An
HTML::Form contains a sequence of inputs. References to theinputs can be obtained with the
$form->inputs or
$form->find_inputmethods. Once you have such a reference, then one of the followingmethods can be used on it:
- $input->type
- Returns the type of this input. Types are stuff like ``text'',``password'', ``hidden'', ``textarea'', ``image'', ``submit'', ``radio'',``checkbox'', ``option''...
- $input->name([$new])
- $input->value([$new])
- These methods can be used to set/get the current name or value of aninput. If the input only can take an enumerated list of values, thenit is an error to try to set it to something else and the method willcroak if you try.
- $input->other_possible_values
- Returns a list of all values not tried yet.
- $input->form_name_value
- Returns a (possible empty) list of key/value pairs that should beincorporated in the form value from this input.
- $input->click($form, $x, $y)
- Some input types (currently ``sumbit'' buttons and ``images") can beclicked to submit the form. The click() method returns thecorrsponding HTTP::Request object.
SEE ALSO
the
LWP manpage, the
HTML::Parser manpage, the
webtestpp manpage
COPYRIGHT
Copyright 1998-1999 Gisle Aas.
This library is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- INPUTS
- SEE ALSO
- COPYRIGHT
This document was created byman2html,using the manual pages.