HTML::Form - Class that represents HTML forms |
HTML::Form - Class that represents HTML forms
use HTML::Form; $form = HTML::Form->parse($html, $base_uri); $form->value(query => "Perl");
use LWP; LWP::UserAgent->new->request($form->click);
Objects of the HTML::Form
class represents a single HTML <form>
... </form> instance. A form consist of a sequence of inputs that
usually have names, and which can take on various values.
The following methods are available:
parse()
to create new HTML::Form objects.
parse()
class method will parse an HTML document and build up
HTML::Form
objects for each <form> found. If called in scalar
context only returns the first <form>. Returns an empty list if there
are 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 parameter
is obtained from the $response->base()
method.
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. In addition to the types possible for <input> HTML tags, we also have ``textarea'' and ``option''. The $no is the sequence number of the input with the indicated $name and/or $type (where 1 is the first).
value()
method can be used to get/set the value of some input. If
no input have the indicated name, then this method will croak.
try_others(\&callback)
input/submit
or
input/image
), with the indicated $name, if specified. You can
optinally specify a coordinate clicked, which only makes a difference
if you clicked on an image. The default coordinate is (1,1).
An HTML::Form
contains a sequence of inputs. References to the
inputs can be obtained with the $form->inputs or $form->find_input
methods. Once you have such a reference, then one of the following
methods can be used on it:
name([$new])
value([$new])
click()
method returns the
corrsponding HTTP::Request
object.
the LWP manpage, the HTML::Parser manpage, webchatpp
Copyright 1998-2000 Gisle Aas.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
HTML::Form - Class that represents HTML forms |