📄 html::form.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...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" '''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 turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "HTML::Form 3".TH HTML::Form 3 "2005-12-07" "perl v5.10.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"HTML::Form \- Class that represents an HTML form element.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 3\& use HTML::Form;\& $form = HTML::Form\->parse($html, $base_uri);\& $form\->value(query => "Perl");\&\& use LWP::UserAgent;\& $ua = LWP::UserAgent\->new;\& $response = $ua\->request($form\->click);.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"Objects of the \f(CW\*(C`HTML::Form\*(C'\fR class represents a single \s-1HTML\s0\&\f(CW\*(C`<form> ... </form>\*(C'\fR instance. A form consists of asequence of inputs that usually have names, and which can take onvarious values. The state of a form can be tweaked and it can then beasked to provide \f(CW\*(C`HTTP::Request\*(C'\fR objects that can be passed to the\&\fIrequest()\fR method of \f(CW\*(C`LWP::UserAgent\*(C'\fR..PPThe following methods are available:.ie n .IP "@forms\fR = HTML::Form\->parse( \f(CW$response )" 4.el .IP "\f(CW@forms\fR = HTML::Form\->parse( \f(CW$response\fR )" 4.IX Item "@forms = HTML::Form->parse( $response )".PD 0.ie n .IP "@forms\fR = HTML::Form\->parse( \f(CW$html_document\fR, \f(CW$base )" 4.el .IP "\f(CW@forms\fR = HTML::Form\->parse( \f(CW$html_document\fR, \f(CW$base\fR )" 4.IX Item "@forms = HTML::Form->parse( $html_document, $base )".ie n .IP "@forms\fR = HTML::Form\->parse( \f(CW$html_document\fR, \f(CW%opt )" 4.el .IP "\f(CW@forms\fR = HTML::Form\->parse( \f(CW$html_document\fR, \f(CW%opt\fR )" 4.IX Item "@forms = HTML::Form->parse( $html_document, %opt )".PDThe \fIparse()\fR class method will parse an \s-1HTML\s0 document and build up\&\f(CW\*(C`HTML::Form\*(C'\fR objects for each <form> element found. If called in scalarcontext only returns the first <form>. Returns an empty list if thereare no forms to be found..SpThe \f(CW$base\fR is the \s-1URI\s0 used to retrieve the \f(CW$html_document\fR. It isneeded to resolve relative action URIs. If the document was retrievedwith \s-1LWP\s0 then this this parameter is obtained from the\&\f(CW$response\fR\->\fIbase()\fR method, as shown by the following example:.Sp.Vb 4\& my $ua = LWP::UserAgent\->new;\& my $response = $ua\->get("http://www.example.com/form.html");\& my @forms = HTML::Form\->parse($response\->decoded_content,\& $response\->base);.Ve.SpThe \fIparse()\fR method can parse from an \f(CW\*(C`HTTP::Response\*(C'\fR objectdirectly, so the example above can be more conveniently written as:.Sp.Vb 3\& my $ua = LWP::UserAgent\->new;\& my $response = $ua\->get("http://www.example.com/form.html");\& my @forms = HTML::Form\->parse($response);.Ve.SpNote that any object that implements a \fIdecoded_content()\fR and \fIbase()\fR methodwith similar behaviour as \f(CW\*(C`HTTP::Response\*(C'\fR will do..SpFinally options might be passed in to control how the parse methodbehaves. The following options are currently recognized:.RS 4.ie n .IP """base""" 4.el .IP "\f(CWbase\fR" 4.IX Item "base"Another way to provide the base \s-1URI\s0..ie n .IP """verbose""" 4.el .IP "\f(CWverbose\fR" 4.IX Item "verbose"Print messages to \s-1STDERR\s0 about any bad \s-1HTML\s0 form constructs found..RE.RS 4.RE.ie n .IP "$method\fR = \f(CW$form\->method" 4.el .IP "\f(CW$method\fR = \f(CW$form\fR\->method" 4.IX Item "$method = $form->method".PD 0.ie n .IP "$form\fR\->method( \f(CW$new_method )" 4.el .IP "\f(CW$form\fR\->method( \f(CW$new_method\fR )" 4.IX Item "$form->method( $new_method )".PDThis method is gets/sets the \fImethod\fR name used for the\&\f(CW\*(C`HTTP::Request\*(C'\fR generated. It is a string like \*(L"\s-1GET\s0\*(R" or \*(L"\s-1POST\s0\*(R"..ie n .IP "$action\fR = \f(CW$form\->action" 4.el .IP "\f(CW$action\fR = \f(CW$form\fR\->action" 4.IX Item "$action = $form->action".PD 0.ie n .IP "$form\fR\->action( \f(CW$new_action )" 4.el .IP "\f(CW$form\fR\->action( \f(CW$new_action\fR )" 4.IX Item "$form->action( $new_action )".PDThis method gets/sets the \s-1URI\s0 which we want to apply the request\&\fImethod\fR to..ie n .IP "$enctype\fR = \f(CW$form\->enctype" 4.el .IP "\f(CW$enctype\fR = \f(CW$form\fR\->enctype" 4.IX Item "$enctype = $form->enctype".PD 0.ie n .IP "$form\fR\->enctype( \f(CW$new_enctype )" 4.el .IP "\f(CW$form\fR\->enctype( \f(CW$new_enctype\fR )" 4.IX Item "$form->enctype( $new_enctype )".PDThis method gets/sets the encoding type for the form data. It is astring like \*(L"application/x\-www\-form\-urlencoded\*(R" or \*(L"multipart/form\-data\*(R"..ie n .IP "$value\fR = \f(CW$form\fR\->attr( \f(CW$name )" 4.el .IP "\f(CW$value\fR = \f(CW$form\fR\->attr( \f(CW$name\fR )" 4.IX Item "$value = $form->attr( $name )".PD 0.ie n .IP "$form\fR\->attr( \f(CW$name\fR, \f(CW$new_value )" 4.el .IP "\f(CW$form\fR\->attr( \f(CW$name\fR, \f(CW$new_value\fR )" 4.IX Item "$form->attr( $name, $new_value )".PDThis method give access to the original \s-1HTML\s0 attributes of the <form> tag.The \f(CW$name\fR should always be passed in lower case..SpExample:.Sp.Vb 4\& @f = HTML::Form\->parse( $html, $foo );\& @f = grep $_\->attr("id") eq "foo", @f;\& die "No form named \*(Aqfoo\*(Aq found" unless @f;\& $foo = shift @f;.Ve.ie n .IP "@inputs\fR = \f(CW$form\->inputs" 4.el .IP "\f(CW@inputs\fR = \f(CW$form\fR\->inputs" 4.IX Item "@inputs = $form->inputs"This method returns the list of inputs in the form. If called inscalar context it returns the number of inputs contained in the form.See \*(L"\s-1INPUTS\s0\*(R" for what methods are available for the input objectsreturned..ie n .IP "$input\fR = \f(CW$form\fR\->find_input( \f(CW$name )" 4.el .IP "\f(CW$input\fR = \f(CW$form\fR\->find_input( \f(CW$name\fR )" 4.IX Item "$input = $form->find_input( $name )".PD 0.ie n .IP "$input\fR = \f(CW$form\fR\->find_input( \f(CW$name\fR, \f(CW$type )" 4.el .IP "\f(CW$input\fR = \f(CW$form\fR\->find_input( \f(CW$name\fR, \f(CW$type\fR )" 4.IX Item "$input = $form->find_input( $name, $type )".ie n .IP "$input\fR = \f(CW$form\fR\->find_input( \f(CW$name\fR, \f(CW$type\fR, \f(CW$index )" 4.el .IP "\f(CW$input\fR = \f(CW$form\fR\->find_input( \f(CW$name\fR, \f(CW$type\fR, \f(CW$index\fR )" 4.IX Item "$input = $form->find_input( $name, $type, $index )".PDThis method is used to locate specific inputs within the form. Allinputs that match the arguments given are returned. In scalar contextonly the first is returned, or \f(CW\*(C`undef\*(C'\fR if none match..SpIf \f(CW$name\fR is specified, then the input must have the indicated name..SpIf \f(CW$type\fR is specified, then the input must have the specified type.The following type names are used: \*(L"text\*(R", \*(L"password\*(R", \*(L"hidden\*(R",\&\*(L"textarea\*(R", \*(L"file\*(R", \*(L"image\*(R", \*(L"submit\*(R", \*(L"radio\*(R", \*(L"checkbox\*(R" and \*(L"option\*(R"..SpThe \f(CW$index\fR is the sequence number of the input matched where 1 is thefirst. If combined with \f(CW$name\fR and/or \f(CW$type\fR then it select the \fIn\fRthinput with the given name and/or type..ie n .IP "$value\fR = \f(CW$form\fR\->value( \f(CW$name )" 4.el .IP "\f(CW$value\fR = \f(CW$form\fR\->value( \f(CW$name\fR )" 4.IX Item "$value = $form->value( $name )"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -