%PDF- %PDF-
Direktori : /usr/share/doc/python3-mechanize/html/ |
Current File : //usr/share/doc/python3-mechanize/html/forms_api.html |
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <title>HTML Forms API — mechanize 0.4.7 documentation</title> <link rel="stylesheet" type="text/css" href="_static/pygments.css" /> <link rel="stylesheet" type="text/css" href="_static/alabaster.css" /> <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Advanced topics" href="advanced.html" /> <link rel="prev" title="Browser API" href="browser_api.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head><body> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <section id="html-forms-api"> <h1>HTML Forms API<a class="headerlink" href="#html-forms-api" title="Permalink to this headline">¶</a></h1> <p>Forms in HTML documents are represented by <a class="reference internal" href="#mechanize.HTMLForm" title="mechanize.HTMLForm"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.HTMLForm</span></code></a>. Every form is a collection of controls. The different types of controls are represented by the various classes documented below.</p> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.HTMLForm"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">HTMLForm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">action</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method='GET'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enctype='application/x-www-form-urlencoded'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">request_class=<class</span> <span class="pre">'mechanize._request.Request'></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">forms=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">labels=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id_to_labels=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding=None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> <p>Represents a single HTML <form> … </form> element.</p> <p>A form consists of a sequence of controls that usually have names, and which can take on various values. The values of the various types of controls represent variously: text, zero-or-one-of-many or many-of-many choices, and files to be uploaded. Some controls can be clicked on to submit the form, and clickable controls’ values sometimes include the coordinates of the click.</p> <p>Forms can be filled in with data to be returned to the server, and then submitted, using the click method to generate a request object suitable for passing to <code class="xref py py-func docutils literal notranslate"><span class="pre">mechanize.urlopen()</span></code> (or the click_request_data or click_pairs methods for integration with third-party code).</p> <p>Usually, HTMLForm instances are not created directly. Instead, they are automatically created when visting a page with a mechanize Browser. If you do construct HTMLForm objects yourself, however, note that an HTMLForm instance is only properly initialised after the fixup method has been called. See <a class="reference internal" href="#mechanize.ListControl" title="mechanize.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.ListControl</span></code></a> for the reason this is required.</p> <p>Indexing a form (form[“control_name”]) returns the named Control’s value attribute. Assignment to a form index (form[“control_name”] = something) is equivalent to assignment to the named Control’s value attribute. If you need to be more specific than just supplying the control’s name, use the set_value and get_value methods.</p> <p>ListControl values are lists of item names (specifically, the names of the items that are selected and not disabled, and hence are “successful” – ie. cause data to be returned to the server). The list item’s name is the value of the corresponding HTML element’s”value” attribute.</p> <p>Example:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">INPUT</span> <span class="nb">type</span><span class="o">=</span><span class="s2">"CHECKBOX"</span> <span class="n">name</span><span class="o">=</span><span class="s2">"cheeses"</span> <span class="n">value</span><span class="o">=</span><span class="s2">"leicester"</span><span class="o">></</span><span class="n">INPUT</span><span class="o">></span> <span class="o"><</span><span class="n">INPUT</span> <span class="nb">type</span><span class="o">=</span><span class="s2">"CHECKBOX"</span> <span class="n">name</span><span class="o">=</span><span class="s2">"cheeses"</span> <span class="n">value</span><span class="o">=</span><span class="s2">"cheddar"</span><span class="o">></</span><span class="n">INPUT</span><span class="o">></span> </pre></div> </div> <p>defines a CHECKBOX control with name “cheeses” which has two items, named “leicester” and “cheddar”.</p> <p>Another example:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">SELECT</span> <span class="n">name</span><span class="o">=</span><span class="s2">"more_cheeses"</span><span class="o">></span> <span class="o"><</span><span class="n">OPTION</span><span class="o">></span><span class="mi">1</span><span class="o"></</span><span class="n">OPTION</span><span class="o">></span> <span class="o"><</span><span class="n">OPTION</span> <span class="n">value</span><span class="o">=</span><span class="s2">"2"</span> <span class="n">label</span><span class="o">=</span><span class="s2">"CHEDDAR"</span><span class="o">></span><span class="n">cheddar</span><span class="o"></</span><span class="n">OPTION</span><span class="o">></span> <span class="o"></</span><span class="n">SELECT</span><span class="o">></span> </pre></div> </div> <p>defines a SELECT control with name “more_cheeses” which has two items, named “1” and “2” (because the OPTION element’s value HTML attribute defaults to the element contents – see <a class="reference internal" href="#mechanize.SelectControl" title="mechanize.SelectControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.SelectControl</span></code></a> for more on these defaulting rules).</p> <p>To select, deselect or otherwise manipulate individual list items, use the <a class="reference internal" href="#mechanize.HTMLForm.find_control" title="mechanize.HTMLForm.find_control"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.HTMLForm.find_control()</span></code></a> and <a class="reference internal" href="#mechanize.ListControl.get" title="mechanize.ListControl.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.ListControl.get()</span></code></a> methods. To set the whole value, do as for any other control: use indexing or the <cite>set_value/get_value</cite> methods.</p> <p>Example:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># select *only* the item named "cheddar"</span> <span class="n">form</span><span class="p">[</span><span class="s2">"cheeses"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"cheddar"</span><span class="p">]</span> <span class="c1"># select "cheddar", leave other items unaffected</span> <span class="n">form</span><span class="o">.</span><span class="n">find_control</span><span class="p">(</span><span class="s2">"cheeses"</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cheddar"</span><span class="p">)</span><span class="o">.</span><span class="n">selected</span> <span class="o">=</span> <span class="kc">True</span> </pre></div> </div> <p>Some controls (RADIO and SELECT without the multiple attribute) can only have zero or one items selected at a time. Some controls (CHECKBOX and SELECT with the multiple attribute) can have multiple items selected at a time. To set the whole value of a ListControl, assign a sequence to a form index:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">form</span><span class="p">[</span><span class="s2">"cheeses"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"cheddar"</span><span class="p">,</span> <span class="s2">"leicester"</span><span class="p">]</span> </pre></div> </div> <p>If the ListControl is not multiple-selection, the assigned list must be of length one.</p> <p>To check if a control has an item, if an item is selected, or if an item is successful (selected and not disabled), respectively:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="s2">"cheddar"</span> <span class="ow">in</span> <span class="p">[</span><span class="n">item</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">form</span><span class="o">.</span><span class="n">find_control</span><span class="p">(</span><span class="s2">"cheeses"</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">]</span> <span class="s2">"cheddar"</span> <span class="ow">in</span> <span class="p">[</span><span class="n">item</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">form</span><span class="o">.</span><span class="n">find_control</span><span class="p">(</span><span class="s2">"cheeses"</span><span class="p">)</span><span class="o">.</span><span class="n">items</span> <span class="ow">and</span> <span class="n">item</span><span class="o">.</span><span class="n">selected</span><span class="p">]</span> <span class="s2">"cheddar"</span> <span class="ow">in</span> <span class="n">form</span><span class="p">[</span><span class="s2">"cheeses"</span><span class="p">]</span> <span class="c1"># or</span> <span class="s2">"cheddar"</span> <span class="ow">in</span> <span class="n">form</span><span class="o">.</span><span class="n">get_value</span><span class="p">(</span><span class="s2">"cheeses"</span><span class="p">)</span> </pre></div> </div> <p>Note that some list items may be disabled (see below).</p> <p>Note the following mistake:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">form</span><span class="p">[</span><span class="n">control_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">control_value</span> <span class="k">assert</span> <span class="n">form</span><span class="p">[</span><span class="n">control_name</span><span class="p">]</span> <span class="o">==</span> <span class="n">control_value</span> <span class="c1"># not necessarily true</span> </pre></div> </div> <p>The reason for this is that form[control_name] always gives the list items in the order they were listed in the HTML.</p> <p>List items (hence list values, too) can be referred to in terms of list item labels rather than list item names using the appropriate label arguments. Note that each item may have several labels.</p> <p>The question of default values of OPTION contents, labels and values is somewhat complicated: see <a class="reference internal" href="#mechanize.SelectControl" title="mechanize.SelectControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.SelectControl</span></code></a> and <a class="reference internal" href="#mechanize.ListControl.get_item_attrs" title="mechanize.ListControl.get_item_attrs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.ListControl.get_item_attrs()</span></code></a> if you think you need to know.</p> <p>Controls can be disabled or readonly. In either case, the control’s value cannot be changed until you clear those flags (see example below). Disabled is the state typically represented by browsers by ‘greying out’ a control. Disabled controls are not ‘successful’ – they don’t cause data to get returned to the server. Readonly controls usually appear in browsers as read-only text boxes. Readonly controls are successful. List items can also be disabled. Attempts to select or deselect disabled items fail with AttributeError.</p> <p>If a lot of controls are readonly, it can be useful to do this:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">form</span><span class="o">.</span><span class="n">set_all_readonly</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span> </pre></div> </div> <p>To clear a control’s value attribute, so that it is not successful (until a value is subsequently set):</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">form</span><span class="o">.</span><span class="n">clear</span><span class="p">(</span><span class="s2">"cheeses"</span><span class="p">)</span> </pre></div> </div> <p>More examples:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">control</span> <span class="o">=</span> <span class="n">form</span><span class="o">.</span><span class="n">find_control</span><span class="p">(</span><span class="s2">"cheeses"</span><span class="p">)</span> <span class="n">control</span><span class="o">.</span><span class="n">disabled</span> <span class="o">=</span> <span class="kc">False</span> <span class="n">control</span><span class="o">.</span><span class="n">readonly</span> <span class="o">=</span> <span class="kc">False</span> <span class="n">control</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"gruyere"</span><span class="p">)</span><span class="o">.</span><span class="n">disabled</span> <span class="o">=</span> <span class="kc">True</span> <span class="n">control</span><span class="o">.</span><span class="n">items</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">selected</span> <span class="o">=</span> <span class="kc">True</span> </pre></div> </div> <p>See the various Control classes for further documentation. Many methods take name, type, kind, id, label and nr arguments to specify the control to be operated on: see <a class="reference internal" href="#mechanize.HTMLForm.find_control" title="mechanize.HTMLForm.find_control"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.HTMLForm.find_control()</span></code></a>.</p> <p>ControlNotFoundError (subclass of ValueError) is raised if the specified control can’t be found. This includes occasions where a non-ListControl is found, but the method (set, for example) requires a ListControl. ItemNotFoundError (subclass of ValueError) is raised if a list item can’t be found. ItemCountError (subclass of ValueError) is raised if an attempt is made to select more than one item and the control doesn’t allow that, or set/get_single are called and the control contains more than one item. AttributeError is raised if a control or item is readonly or disabled and an attempt is made to alter its value.</p> <p>Security note: Remember that any passwords you store in HTMLForm instances will be saved to disk in the clear if you pickle them (directly or indirectly). The simplest solution to this is to avoid pickling HTMLForm objects. You could also pickle before filling in any password, or just set the password to “” before pickling.</p> <p>Public attributes:</p> <dl class="field-list simple"> <dt class="field-odd">Variables</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>action</strong> – full (absolute URI) form action</p></li> <li><p><strong>method</strong> – “GET” or “POST”</p></li> <li><p><strong>enctype</strong> – form transfer encoding MIME type</p></li> <li><p><strong>name</strong> – name of form (None if no name was specified)</p></li> <li><p><strong>attrs</strong> – dictionary mapping original HTML form attributes to their values</p></li> <li><p><strong>controls</strong> – list of Control instances; do not alter this list (instead, call form.new_control to make a Control and add it to the form, or control.add_to_form if you already have a Control instance)</p></li> </ul> </dd> </dl> <p>Methods for form filling:</p> <p>Most of the these methods have very similar arguments. See <a class="reference internal" href="#mechanize.HTMLForm.find_control" title="mechanize.HTMLForm.find_control"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.HTMLForm.find_control()</span></code></a> for details of the name, type, kind, label and nr arguments.</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">find_control</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">predicate</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="n">get_value</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">by_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="c1"># by_label is deprecated</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="n">set_value</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">by_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="c1"># by_label is deprecated</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="n">clear_all</span><span class="p">()</span> <span class="n">clear</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="n">set_all_readonly</span><span class="p">(</span><span class="n">readonly</span><span class="p">)</span> </pre></div> </div> <p>Method applying only to FileControls:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">add_file</span><span class="p">(</span><span class="n">file_object</span><span class="p">,</span> <span class="n">content_type</span><span class="o">=</span><span class="s2">"application/octet-stream"</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> </pre></div> </div> <p>Methods applying only to clickable controls:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">click</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">coord</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="n">click_request_data</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">coord</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="n">click_pairs</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">coord</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> </pre></div> </div> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.add_file"> <span class="sig-name descname"><span class="pre">add_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_object</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">content_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.add_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.add_file" title="Permalink to this definition">¶</a></dt> <dd><p>Add a file to be uploaded.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>file_object</strong> – file-like object (with read method) from which to read data to upload</p></li> <li><p><strong>content_type</strong> – MIME content type of data to upload</p></li> <li><p><strong>filename</strong> – filename to pass to server</p></li> </ul> </dd> </dl> <p>If filename is None, no filename is sent to the server.</p> <p>If content_type is None, the content type is guessed based on the filename and the data from read from the file object.</p> <p>At the moment, guessed content type is always application/octet-stream.</p> <p>Note the following useful HTML attributes of file upload controls (see HTML 4.01 spec, section 17):</p> <blockquote> <div><ul class="simple"> <li><dl class="simple"> <dt><cite>accept</cite>: comma-separated list of content types</dt><dd><p>that the server will handle correctly; you can use this to filter out non-conforming files</p> </dd> </dl> </li> <li><dl class="simple"> <dt><cite>size</cite>: XXX IIRC, this is indicative of whether form</dt><dd><p>wants multiple or single files</p> </dd> </dl> </li> <li><p><cite>maxlength</cite>: XXX hint of max content length in bytes?</p></li> </ul> </div></blockquote> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.clear"> <span class="sig-name descname"><span class="pre">clear</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.clear"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.clear" title="Permalink to this definition">¶</a></dt> <dd><p>Clear the value attribute of a control.</p> <p>As a result, the affected control will not be successful until a value is subsequently set. AttributeError is raised on readonly controls.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.clear_all"> <span class="sig-name descname"><span class="pre">clear_all</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.clear_all"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.clear_all" title="Permalink to this definition">¶</a></dt> <dd><p>Clear the value attributes of all controls in the form.</p> <p>See <a class="reference internal" href="#mechanize.HTMLForm.clear" title="mechanize.HTMLForm.clear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.HTMLForm.clear()</span></code></a></p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.click"> <span class="sig-name descname"><span class="pre">click</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr=0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coord=(1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">request_class=<class</span> <span class="pre">'mechanize._request.Request'></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label=None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.click"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.click" title="Permalink to this definition">¶</a></dt> <dd><p>Return request that would result from clicking on a control.</p> <p>The request object is a mechanize.Request instance, which you can pass to mechanize.urlopen.</p> <p>Only some control types (INPUT/SUBMIT & BUTTON/SUBMIT buttons and IMAGEs) can be clicked.</p> <p>Will click on the first clickable control, subject to the name, type and nr arguments (as for find_control). If no name, type, id or number is specified and there are no clickable controls, a request will be returned for the form in its current, un-clicked, state.</p> <p>IndexError is raised if any of name, type, id or nr is specified but no matching control is found. ValueError is raised if the HTMLForm has an enctype attribute that is not recognised.</p> <p>You can optionally specify a coordinate to click at, which only makes a difference if you clicked on an image.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.click_pairs"> <span class="sig-name descname"><span class="pre">click_pairs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coord</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.click_pairs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.click_pairs" title="Permalink to this definition">¶</a></dt> <dd><p>As for click_request_data, but returns a list of (key, value) pairs.</p> <p>You can use this list as an argument to urllib.urlencode. This is usually only useful if you’re using httplib or urllib rather than mechanize. It may also be useful if you want to manually tweak the keys and/or values, but this should not be necessary. Otherwise, use the click method.</p> <p>Note that this method is only useful for forms of MIME type x-www-form-urlencoded. In particular, it does not return the information required for file upload. If you need file upload and are not using mechanize, use click_request_data.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.click_request_data"> <span class="sig-name descname"><span class="pre">click_request_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr=0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coord=(1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">request_class=<class</span> <span class="pre">'mechanize._request.Request'></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label=None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.click_request_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.click_request_data" title="Permalink to this definition">¶</a></dt> <dd><p>As for click method, but return a tuple (url, data, headers).</p> <p>You can use this data to send a request to the server. This is useful if you’re using httplib or urllib rather than mechanize. Otherwise, use the click method.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.find_control"> <span class="sig-name descname"><span class="pre">find_control</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">predicate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.find_control"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.find_control" title="Permalink to this definition">¶</a></dt> <dd><p>Locate and return some specific control within the form.</p> <p>At least one of the name, type, kind, predicate and nr arguments must be supplied. If no matching control is found, ControlNotFoundError is raised.</p> <p>If name is specified, then the control must have the indicated name.</p> <p>If type is specified then the control must have the specified type (in addition to the types possible for <input> HTML tags: “text”, “password”, “hidden”, “submit”, “image”, “button”, “radio”, “checkbox”, “file” we also have “reset”, “buttonbutton”, “submitbutton”, “resetbutton”, “textarea”, “select”).</p> <p>If kind is specified, then the control must fall into the specified group, each of which satisfies a particular interface. The types are “text”, “list”, “multilist”, “singlelist”, “clickable” and “file”.</p> <p>If id is specified, then the control must have the indicated id.</p> <p>If predicate is specified, then the control must match that function. The predicate function is passed the control as its single argument, and should return a boolean value indicating whether the control matched.</p> <p>nr, if supplied, is the sequence number of the control (where 0 is the first). Note that control 0 is the first control matching all the other arguments (if supplied); it is not necessarily the first control in the form. If no nr is supplied, AmbiguityError is raised if multiple controls match the other arguments.</p> <p>If label is specified, then the control must have this label. Note that radio controls and checkboxes never have labels: their items do.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.fixup"> <span class="sig-name descname"><span class="pre">fixup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.fixup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.fixup" title="Permalink to this definition">¶</a></dt> <dd><p>Normalise form after all controls have been added.</p> <p>This is usually called by ParseFile and ParseResponse. Don’t call it youself unless you’re building your own Control instances.</p> <p>This method should only be called once, after all controls have been added to the form.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.get_value"> <span class="sig-name descname"><span class="pre">get_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.get_value"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.get_value" title="Permalink to this definition">¶</a></dt> <dd><p>Return value of control.</p> <p>If only name and value arguments are supplied, equivalent to</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">form</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> </pre></div> </div> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.get_value_by_label"> <span class="sig-name descname"><span class="pre">get_value_by_label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.get_value_by_label"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.get_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>All arguments should be passed by name.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.new_control"> <span class="sig-name descname"><span class="pre">new_control</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignore_unknown</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.new_control"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.new_control" title="Permalink to this definition">¶</a></dt> <dd><p>Adds a new control to the form.</p> <p>This is usually called by mechanize. Don’t call it yourself unless you’re building your own Control instances.</p> <p>Note that controls representing lists of items are built up from controls holding only a single list item. See <a class="reference internal" href="#mechanize.ListControl" title="mechanize.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.ListControl</span></code></a> for further information.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>type</strong> – type of control (see <a class="reference internal" href="#mechanize.Control" title="mechanize.Control"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Control</span></code></a> for a list)</p></li> <li><p><strong>attrs</strong> – HTML attributes of control</p></li> <li><p><strong>ignore_unknown</strong> – if true, use a dummy Control instance for controls of unknown type; otherwise, use a TextControl</p></li> <li><p><strong>select_default</strong> – for RADIO and multiple-selection SELECT controls, pick the first item as the default if no ‘selected’ HTML attribute is present (this defaulting happens when the HTMLForm.fixup method is called)</p></li> <li><p><strong>index</strong> – index of corresponding element in HTML (see MoreFormTests.test_interspersed_controls for motivation)</p></li> </ul> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.possible_items"> <span class="sig-name descname"><span class="pre">possible_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.possible_items"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.possible_items" title="Permalink to this definition">¶</a></dt> <dd><p>Return a list of all values that the specified control can take.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.set"> <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">item_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.set" title="Permalink to this definition">¶</a></dt> <dd><p>Select / deselect named list item.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>selected</strong> – boolean selected state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.set_single"> <span class="sig-name descname"><span class="pre">set_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.set_single"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.set_single" title="Permalink to this definition">¶</a></dt> <dd><p>Select / deselect list item in a control having only one item.</p> <p>If the control has multiple list items, ItemCountError is raised.</p> <p>This is just a convenience method, so you don’t need to know the item’s name – the item name in these single-item controls is usually something meaningless like “1” or “on”.</p> <p>For example, if a checkbox has a single item named “on”, the following two calls are equivalent:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">control</span><span class="o">.</span><span class="n">toggle</span><span class="p">(</span><span class="s2">"on"</span><span class="p">)</span> <span class="n">control</span><span class="o">.</span><span class="n">toggle_single</span><span class="p">()</span> </pre></div> </div> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.set_value"> <span class="sig-name descname"><span class="pre">set_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.set_value"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.set_value" title="Permalink to this definition">¶</a></dt> <dd><p>Set value of control.</p> <p>If only name and value arguments are supplied, equivalent to</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">form</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span> </pre></div> </div> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.set_value_by_label"> <span class="sig-name descname"><span class="pre">set_value_by_label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.set_value_by_label"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.set_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>All arguments should be passed by name.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.toggle"> <span class="sig-name descname"><span class="pre">toggle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">item_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.toggle"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.toggle" title="Permalink to this definition">¶</a></dt> <dd><p>Toggle selected state of named list item.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.HTMLForm.toggle_single"> <span class="sig-name descname"><span class="pre">toggle_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kind</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#HTMLForm.toggle_single"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.HTMLForm.toggle_single" title="Permalink to this definition">¶</a></dt> <dd><p>Toggle selected state of list item in control having only one item.</p> <p>The rest is as for <a class="reference internal" href="#mechanize.HTMLForm.set_single" title="mechanize.HTMLForm.set_single"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.HTMLForm.set_single()</span></code></a></p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.Control"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">Control</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#Control"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Control" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> <p>An HTML form control.</p> <p>An HTMLForm contains a sequence of Controls. The Controls in an HTMLForm are accessed using the HTMLForm.find_control method or the HTMLForm.controls attribute.</p> <p>Control instances are usually constructed using the ParseFile / ParseResponse functions. If you use those functions, you can ignore the rest of this paragraph. A Control is only properly initialised after the fixup method has been called. In fact, this is only strictly necessary for ListControl instances. This is necessary because ListControls are built up from ListControls each containing only a single item, and their initial value(s) can only be known after the sequence is complete.</p> <p>The types and values that are acceptable for assignment to the value attribute are defined by subclasses.</p> <p>If the disabled attribute is true, this represents the state typically represented by browsers by ‘greying out’ a control. If the disabled attribute is true, the Control will raise AttributeError if an attempt is made to change its value. In addition, the control will not be considered ‘successful’ as defined by the W3C HTML 4 standard – ie. it will contribute no data to the return value of the HTMLForm.click* methods. To enable a control, set the disabled attribute to a false value.</p> <p>If the readonly attribute is true, the Control will raise AttributeError if an attempt is made to change its value. To make a control writable, set the readonly attribute to a false value.</p> <p>All controls have the disabled and readonly attributes, not only those that may have the HTML attributes of the same names.</p> <p>On assignment to the value attribute, the following exceptions are raised: TypeError, AttributeError (if the value attribute should not be assigned to, because the control is disabled, for example) and ValueError.</p> <p>If the name or value attributes are None, or the value is an empty list, or if the control is disabled, the control is not successful.</p> <p>Public attributes:</p> <dl class="field-list simple"> <dt class="field-odd">Variables</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>type</strong> (<em>str</em>) – string describing type of control (see the keys of the HTMLForm.type2class dictionary for the allowable values) (readonly)</p></li> <li><p><strong>name</strong> (<em>str</em>) – name of control (readonly)</p></li> <li><p><strong>value</strong> – current value of control (subclasses may allow a single value, a sequence of values, or either)</p></li> <li><p><strong>disabled</strong> (<em>bool</em>) – disabled state</p></li> <li><p><strong>readonly</strong> (<em>bool</em>) – readonly state</p></li> <li><p><strong>id</strong> (<em>str</em>) – value of id HTML attribute</p></li> </ul> </dd> </dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.Control.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#Control.get_labels"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Control.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.Control.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#Control.pairs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Control.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.ScalarControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">ScalarControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ScalarControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ScalarControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.Control" title="mechanize._form_controls.Control"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.Control</span></code></a></p> <p>Control whose value is not restricted to one of a prescribed set.</p> <p>Some ScalarControls don’t accept any value attribute. Otherwise, takes a single value, which must be string-like.</p> <p>Additional read-only public attribute:</p> <dl class="field-list simple"> <dt class="field-odd">Variables</dt> <dd class="field-odd"><p><strong>attrs</strong> (<em>dict</em>) – dictionary mapping the names of original HTML attributes of the control to their values</p> </dd> </dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ScalarControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.ScalarControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ScalarControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.ScalarControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.TextControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">TextControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#TextControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.TextControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.ScalarControl" title="mechanize._form_controls.ScalarControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.ScalarControl</span></code></a></p> <p>Textual input control.</p> <p>Covers HTML elements: INPUT/TEXT, INPUT/PASSWORD, INPUT/HIDDEN, TEXTAREA</p> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.TextControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.TextControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.TextControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.TextControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.FileControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">FileControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#FileControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.FileControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.ScalarControl" title="mechanize._form_controls.ScalarControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.ScalarControl</span></code></a></p> <p>File upload with INPUT TYPE=FILE.</p> <p>The value attribute of a FileControl is always None. Use add_file instead.</p> <p>Additional public method: <a class="reference internal" href="#mechanize.FileControl.add_file" title="mechanize.FileControl.add_file"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_file()</span></code></a></p> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.FileControl.add_file"> <span class="sig-name descname"><span class="pre">add_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_object</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">content_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#FileControl.add_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.FileControl.add_file" title="Permalink to this definition">¶</a></dt> <dd><p>Add data from the specified file to be uploaded. content_type and filename are sent in the HTTP headers if specified.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.FileControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.FileControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.FileControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.FileControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.IgnoreControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">IgnoreControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#IgnoreControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.IgnoreControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.ScalarControl" title="mechanize._form_controls.ScalarControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.ScalarControl</span></code></a></p> <p>Control that we’re not interested in.</p> <p>Covers html elements: INPUT/RESET, BUTTON/RESET, INPUT/BUTTON, BUTTON/BUTTON</p> <p>These controls are always unsuccessful, in the terminology of HTML 4 (ie. they never require any information to be returned to the server).</p> <p>BUTTON/BUTTON is used to generate events for script embedded in HTML.</p> <p>The value attribute of IgnoreControl is always None.</p> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.IgnoreControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.IgnoreControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.IgnoreControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.IgnoreControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.ListControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">ListControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">called_as_base_class</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.Control" title="mechanize._form_controls.Control"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.Control</span></code></a></p> <p>Control representing a sequence of items.</p> <p>The value attribute of a ListControl represents the successful list items in the control. The successful list items are those that are selected and not disabled.</p> <p>ListControl implements both list controls that take a length-1 value (single-selection) and those that take length >1 values (multiple-selection).</p> <p>ListControls accept sequence values only. Some controls only accept sequences of length 0 or 1 (RADIO, and single-selection SELECT). In those cases, ItemCountError is raised if len(sequence) > 1. CHECKBOXes and multiple-selection SELECTs (those having the “multiple” HTML attribute) accept sequences of any length.</p> <p>Note the following mistake:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">control</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">some_value</span> <span class="k">assert</span> <span class="n">control</span><span class="o">.</span><span class="n">value</span> <span class="o">==</span> <span class="n">some_value</span> <span class="c1"># not necessarily true</span> </pre></div> </div> <p>The reason for this is that the value attribute always gives the list items in the order they were listed in the HTML.</p> <p>ListControl items can also be referred to by their labels instead of names. Use the label argument to .get(), and the .set_value_by_label(), .get_value_by_label() methods.</p> <p>Note that, rather confusingly, though SELECT controls are represented in HTML by SELECT elements (which contain OPTION elements, representing individual list items), CHECKBOXes and RADIOs are not represented by <em>any</em> element. Instead, those controls are represented by a collection of INPUT elements. For example, this is a SELECT control, named “control1”:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">select</span> <span class="n">name</span><span class="o">=</span><span class="s2">"control1"</span><span class="o">></span> <span class="o"><</span><span class="n">option</span><span class="o">></span><span class="n">foo</span><span class="o"></</span><span class="n">option</span><span class="o">></span> <span class="o"><</span><span class="n">option</span> <span class="n">value</span><span class="o">=</span><span class="s2">"1"</span><span class="o">></span><span class="n">bar</span><span class="o"></</span><span class="n">option</span><span class="o">></span> <span class="o"></</span><span class="n">select</span><span class="o">></span> </pre></div> </div> <p>and this is a CHECKBOX control, named “control2”:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="nb">input</span> <span class="nb">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="n">name</span><span class="o">=</span><span class="s2">"control2"</span> <span class="n">value</span><span class="o">=</span><span class="s2">"foo"</span> <span class="nb">id</span><span class="o">=</span><span class="s2">"cbe1"</span><span class="o">></span> <span class="o"><</span><span class="nb">input</span> <span class="nb">type</span><span class="o">=</span><span class="s2">"checkbox"</span> <span class="n">name</span><span class="o">=</span><span class="s2">"control2"</span> <span class="n">value</span><span class="o">=</span><span class="s2">"bar"</span> <span class="nb">id</span><span class="o">=</span><span class="s2">"cbe2"</span><span class="o">></span> </pre></div> </div> <p>The id attribute of a CHECKBOX or RADIO ListControl is always that of its first element (for example, “cbe1” above).</p> <p>Additional read-only public attribute: multiple.</p> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.fixup"> <span class="sig-name descname"><span class="pre">fixup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.fixup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.fixup" title="Permalink to this definition">¶</a></dt> <dd><p>ListControls are built up from component list items (which are also ListControls) during parsing. This method should be called after all items have been added. See <a class="reference internal" href="#mechanize.ListControl" title="mechanize.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.ListControl</span></code></a> for the reason this is required.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.get"> <span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.get"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.get" title="Permalink to this definition">¶</a></dt> <dd><p>Return item by name or label, disambiguating if necessary with nr.</p> <p>All arguments must be passed by name, with the exception of ‘name’, which may be used as a positional argument.</p> <p>If name is specified, then the item must have the indicated name.</p> <p>If label is specified, then the item must have a label whose whitespace-compressed, stripped, text substring-matches the indicated label string (e.g. label=”please choose” will match ” Do please choose an item “).</p> <p>If id is specified, then the item must have the indicated id.</p> <p>nr is an optional 0-based index of the items matching the query.</p> <p>If nr is the default None value and more than item is found, raises AmbiguityError.</p> <p>If no item is found, or if items are found but nr is specified and not found, raises ItemNotFoundError.</p> <p>Optionally excludes disabled items.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.get_item_attrs"> <span class="sig-name descname"><span class="pre">get_item_attrs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.get_item_attrs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.get_item_attrs" title="Permalink to this definition">¶</a></dt> <dd><p>Return dictionary of HTML attributes for a single ListControl item.</p> <p>The HTML element types that describe list items are: OPTION for SELECT controls, INPUT for the rest. These elements have HTML attributes that you may occasionally want to know about – for example, the “alt” HTML attribute gives a text string describing the item (graphical browsers usually display this as a tooltip).</p> <p>The returned dictionary maps HTML attribute names to values. The names and values are taken from the original HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.get_item_disabled"> <span class="sig-name descname"><span class="pre">get_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.get_item_disabled"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.get_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Get disabled state of named list item in a ListControl.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.get_items"> <span class="sig-name descname"><span class="pre">get_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.get_items"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.get_items" title="Permalink to this definition">¶</a></dt> <dd><p>Return matching items by name or label.</p> <p>For argument docs, see the docstring for .get()</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.ListControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.get_value_by_label"> <span class="sig-name descname"><span class="pre">get_value_by_label</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.get_value_by_label"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.get_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the control as given by normalized labels.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.ListControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.possible_items"> <span class="sig-name descname"><span class="pre">possible_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.possible_items"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.possible_items" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: return the names or labels of all possible items.</p> <p>Includes disabled items, which may be misleading for some use cases.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.set"> <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.set" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, set the matching item’s selection to the bool value of selected.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.set_all_items_disabled"> <span class="sig-name descname"><span class="pre">set_all_items_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.set_all_items_disabled"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.set_all_items_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of all list items in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.set_item_disabled"> <span class="sig-name descname"><span class="pre">set_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.set_item_disabled"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.set_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of named list item in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.set_single"> <span class="sig-name descname"><span class="pre">set_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.set_single"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.set_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: set the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.set_value_by_label"> <span class="sig-name descname"><span class="pre">set_value_by_label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.set_value_by_label"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.set_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Set the value of control by item labels.</p> <p>value is expected to be an iterable of strings that are substrings of the item labels that should be selected. Before substring matching is performed, the original label text is whitespace-compressed (consecutive whitespace characters are converted to a single space character) and leading and trailing whitespace is stripped. Ambiguous labels: it will not complain as long as all ambiguous labels share the same item name (e.g. OPTION value).</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.toggle"> <span class="sig-name descname"><span class="pre">toggle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.toggle"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.toggle" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, toggle the matching item’s selection.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ListControl.toggle_single"> <span class="sig-name descname"><span class="pre">toggle_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ListControl.toggle_single"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ListControl.toggle_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: toggle the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.RadioControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">RadioControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#RadioControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.RadioControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.ListControl" title="mechanize._form_controls.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.ListControl</span></code></a></p> <p>Covers:</p> <p>INPUT/RADIO</p> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.fixup"> <span class="sig-name descname"><span class="pre">fixup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#RadioControl.fixup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.RadioControl.fixup" title="Permalink to this definition">¶</a></dt> <dd><p>ListControls are built up from component list items (which are also ListControls) during parsing. This method should be called after all items have been added. See <a class="reference internal" href="#mechanize.ListControl" title="mechanize.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.ListControl</span></code></a> for the reason this is required.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.get"> <span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.get" title="Permalink to this definition">¶</a></dt> <dd><p>Return item by name or label, disambiguating if necessary with nr.</p> <p>All arguments must be passed by name, with the exception of ‘name’, which may be used as a positional argument.</p> <p>If name is specified, then the item must have the indicated name.</p> <p>If label is specified, then the item must have a label whose whitespace-compressed, stripped, text substring-matches the indicated label string (e.g. label=”please choose” will match ” Do please choose an item “).</p> <p>If id is specified, then the item must have the indicated id.</p> <p>nr is an optional 0-based index of the items matching the query.</p> <p>If nr is the default None value and more than item is found, raises AmbiguityError.</p> <p>If no item is found, or if items are found but nr is specified and not found, raises ItemNotFoundError.</p> <p>Optionally excludes disabled items.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.get_item_attrs"> <span class="sig-name descname"><span class="pre">get_item_attrs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.get_item_attrs" title="Permalink to this definition">¶</a></dt> <dd><p>Return dictionary of HTML attributes for a single ListControl item.</p> <p>The HTML element types that describe list items are: OPTION for SELECT controls, INPUT for the rest. These elements have HTML attributes that you may occasionally want to know about – for example, the “alt” HTML attribute gives a text string describing the item (graphical browsers usually display this as a tooltip).</p> <p>The returned dictionary maps HTML attribute names to values. The names and values are taken from the original HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.get_item_disabled"> <span class="sig-name descname"><span class="pre">get_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.get_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Get disabled state of named list item in a ListControl.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.get_items"> <span class="sig-name descname"><span class="pre">get_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.get_items" title="Permalink to this definition">¶</a></dt> <dd><p>Return matching items by name or label.</p> <p>For argument docs, see the docstring for .get()</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#RadioControl.get_labels"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.RadioControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.get_value_by_label"> <span class="sig-name descname"><span class="pre">get_value_by_label</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.get_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the control as given by normalized labels.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.possible_items"> <span class="sig-name descname"><span class="pre">possible_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.possible_items" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: return the names or labels of all possible items.</p> <p>Includes disabled items, which may be misleading for some use cases.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.set"> <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.set" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, set the matching item’s selection to the bool value of selected.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.set_all_items_disabled"> <span class="sig-name descname"><span class="pre">set_all_items_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.set_all_items_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of all list items in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.set_item_disabled"> <span class="sig-name descname"><span class="pre">set_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.set_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of named list item in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.set_single"> <span class="sig-name descname"><span class="pre">set_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.set_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: set the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.set_value_by_label"> <span class="sig-name descname"><span class="pre">set_value_by_label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.set_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Set the value of control by item labels.</p> <p>value is expected to be an iterable of strings that are substrings of the item labels that should be selected. Before substring matching is performed, the original label text is whitespace-compressed (consecutive whitespace characters are converted to a single space character) and leading and trailing whitespace is stripped. Ambiguous labels: it will not complain as long as all ambiguous labels share the same item name (e.g. OPTION value).</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.toggle"> <span class="sig-name descname"><span class="pre">toggle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.toggle" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, toggle the matching item’s selection.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.RadioControl.toggle_single"> <span class="sig-name descname"><span class="pre">toggle_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.RadioControl.toggle_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: toggle the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.CheckboxControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">CheckboxControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#CheckboxControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.CheckboxControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.ListControl" title="mechanize._form_controls.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.ListControl</span></code></a></p> <p>Covers:</p> <p>INPUT/CHECKBOX</p> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.fixup"> <span class="sig-name descname"><span class="pre">fixup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.fixup" title="Permalink to this definition">¶</a></dt> <dd><p>ListControls are built up from component list items (which are also ListControls) during parsing. This method should be called after all items have been added. See <a class="reference internal" href="#mechanize.ListControl" title="mechanize.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.ListControl</span></code></a> for the reason this is required.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.get"> <span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.get" title="Permalink to this definition">¶</a></dt> <dd><p>Return item by name or label, disambiguating if necessary with nr.</p> <p>All arguments must be passed by name, with the exception of ‘name’, which may be used as a positional argument.</p> <p>If name is specified, then the item must have the indicated name.</p> <p>If label is specified, then the item must have a label whose whitespace-compressed, stripped, text substring-matches the indicated label string (e.g. label=”please choose” will match ” Do please choose an item “).</p> <p>If id is specified, then the item must have the indicated id.</p> <p>nr is an optional 0-based index of the items matching the query.</p> <p>If nr is the default None value and more than item is found, raises AmbiguityError.</p> <p>If no item is found, or if items are found but nr is specified and not found, raises ItemNotFoundError.</p> <p>Optionally excludes disabled items.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.get_item_attrs"> <span class="sig-name descname"><span class="pre">get_item_attrs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.get_item_attrs" title="Permalink to this definition">¶</a></dt> <dd><p>Return dictionary of HTML attributes for a single ListControl item.</p> <p>The HTML element types that describe list items are: OPTION for SELECT controls, INPUT for the rest. These elements have HTML attributes that you may occasionally want to know about – for example, the “alt” HTML attribute gives a text string describing the item (graphical browsers usually display this as a tooltip).</p> <p>The returned dictionary maps HTML attribute names to values. The names and values are taken from the original HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.get_item_disabled"> <span class="sig-name descname"><span class="pre">get_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.get_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Get disabled state of named list item in a ListControl.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.get_items"> <span class="sig-name descname"><span class="pre">get_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.get_items" title="Permalink to this definition">¶</a></dt> <dd><p>Return matching items by name or label.</p> <p>For argument docs, see the docstring for .get()</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#CheckboxControl.get_labels"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.CheckboxControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.get_value_by_label"> <span class="sig-name descname"><span class="pre">get_value_by_label</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.get_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the control as given by normalized labels.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.possible_items"> <span class="sig-name descname"><span class="pre">possible_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.possible_items" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: return the names or labels of all possible items.</p> <p>Includes disabled items, which may be misleading for some use cases.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.set"> <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.set" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, set the matching item’s selection to the bool value of selected.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.set_all_items_disabled"> <span class="sig-name descname"><span class="pre">set_all_items_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.set_all_items_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of all list items in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.set_item_disabled"> <span class="sig-name descname"><span class="pre">set_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.set_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of named list item in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.set_single"> <span class="sig-name descname"><span class="pre">set_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.set_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: set the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.set_value_by_label"> <span class="sig-name descname"><span class="pre">set_value_by_label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.set_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Set the value of control by item labels.</p> <p>value is expected to be an iterable of strings that are substrings of the item labels that should be selected. Before substring matching is performed, the original label text is whitespace-compressed (consecutive whitespace characters are converted to a single space character) and leading and trailing whitespace is stripped. Ambiguous labels: it will not complain as long as all ambiguous labels share the same item name (e.g. OPTION value).</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.toggle"> <span class="sig-name descname"><span class="pre">toggle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.toggle" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, toggle the matching item’s selection.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.CheckboxControl.toggle_single"> <span class="sig-name descname"><span class="pre">toggle_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.CheckboxControl.toggle_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: toggle the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.SelectControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">SelectControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#SelectControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.SelectControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.ListControl" title="mechanize._form_controls.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.ListControl</span></code></a></p> <p>Covers:</p> <p>SELECT (and OPTION)</p> <p>OPTION ‘values’, in HTML parlance, are Item ‘names’ in mechanize parlance.</p> <p>SELECT control values and labels are subject to some messy defaulting rules. For example, if the HTML representation of the control is:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">SELECT</span> <span class="n">name</span><span class="o">=</span><span class="n">year</span><span class="o">></span> <span class="o"><</span><span class="n">OPTION</span> <span class="n">value</span><span class="o">=</span><span class="mi">0</span> <span class="n">label</span><span class="o">=</span><span class="s2">"2002"</span><span class="o">></span><span class="n">current</span> <span class="n">year</span><span class="o"></</span><span class="n">OPTION</span><span class="o">></span> <span class="o"><</span><span class="n">OPTION</span> <span class="n">value</span><span class="o">=</span><span class="mi">1</span><span class="o">></span><span class="mi">2001</span><span class="o"></</span><span class="n">OPTION</span><span class="o">></span> <span class="o"><</span><span class="n">OPTION</span><span class="o">></span><span class="mi">2000</span><span class="o"></</span><span class="n">OPTION</span><span class="o">></span> <span class="o"></</span><span class="n">SELECT</span><span class="o">></span> </pre></div> </div> <p>The items, in order, have labels “2002”, “2001” and “2000”, whereas their names (the OPTION values) are “0”, “1” and “2000” respectively. Note that the value of the last OPTION in this example defaults to its contents, as specified by RFC 1866, as do the labels of the second and third OPTIONs.</p> <p>The OPTION labels are sometimes more meaningful than the OPTION values, which can make for more maintainable code.</p> <p>Additional read-only public attribute: attrs</p> <p>The attrs attribute is a dictionary of the original HTML attributes of the SELECT element. Other ListControls do not have this attribute, because in other cases the control as a whole does not correspond to any single HTML element. control.get(…).attrs may be used as usual to get at the HTML attributes of the HTML elements corresponding to individual list items (for SELECT controls, these are OPTION elements).</p> <p>Another special case is that the Item.attrs dictionaries have a special key “contents” which does not correspond to any real HTML attribute, but rather contains the contents of the OPTION element:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">OPTION</span><span class="o">></span><span class="n">this</span> <span class="n">bit</span><span class="o"></</span><span class="n">OPTION</span><span class="o">></span> </pre></div> </div> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.fixup"> <span class="sig-name descname"><span class="pre">fixup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#SelectControl.fixup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.SelectControl.fixup" title="Permalink to this definition">¶</a></dt> <dd><p>ListControls are built up from component list items (which are also ListControls) during parsing. This method should be called after all items have been added. See <a class="reference internal" href="#mechanize.ListControl" title="mechanize.ListControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.ListControl</span></code></a> for the reason this is required.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.get"> <span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.get" title="Permalink to this definition">¶</a></dt> <dd><p>Return item by name or label, disambiguating if necessary with nr.</p> <p>All arguments must be passed by name, with the exception of ‘name’, which may be used as a positional argument.</p> <p>If name is specified, then the item must have the indicated name.</p> <p>If label is specified, then the item must have a label whose whitespace-compressed, stripped, text substring-matches the indicated label string (e.g. label=”please choose” will match ” Do please choose an item “).</p> <p>If id is specified, then the item must have the indicated id.</p> <p>nr is an optional 0-based index of the items matching the query.</p> <p>If nr is the default None value and more than item is found, raises AmbiguityError.</p> <p>If no item is found, or if items are found but nr is specified and not found, raises ItemNotFoundError.</p> <p>Optionally excludes disabled items.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.get_item_attrs"> <span class="sig-name descname"><span class="pre">get_item_attrs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.get_item_attrs" title="Permalink to this definition">¶</a></dt> <dd><p>Return dictionary of HTML attributes for a single ListControl item.</p> <p>The HTML element types that describe list items are: OPTION for SELECT controls, INPUT for the rest. These elements have HTML attributes that you may occasionally want to know about – for example, the “alt” HTML attribute gives a text string describing the item (graphical browsers usually display this as a tooltip).</p> <p>The returned dictionary maps HTML attribute names to values. The names and values are taken from the original HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.get_item_disabled"> <span class="sig-name descname"><span class="pre">get_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.get_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Get disabled state of named list item in a ListControl.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.get_items"> <span class="sig-name descname"><span class="pre">get_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exclude_disabled</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.get_items" title="Permalink to this definition">¶</a></dt> <dd><p>Return matching items by name or label.</p> <p>For argument docs, see the docstring for .get()</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.get_value_by_label"> <span class="sig-name descname"><span class="pre">get_value_by_label</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.get_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value of the control as given by normalized labels.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.possible_items"> <span class="sig-name descname"><span class="pre">possible_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.possible_items" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: return the names or labels of all possible items.</p> <p>Includes disabled items, which may be misleading for some use cases.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.set"> <span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.set" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, set the matching item’s selection to the bool value of selected.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.set_all_items_disabled"> <span class="sig-name descname"><span class="pre">set_all_items_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.set_all_items_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of all list items in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.set_item_disabled"> <span class="sig-name descname"><span class="pre">set_item_disabled</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">disabled</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.set_item_disabled" title="Permalink to this definition">¶</a></dt> <dd><p>Set disabled state of named list item in a ListControl.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>disabled</strong> – boolean disabled state</p> </dd> </dl> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.set_single"> <span class="sig-name descname"><span class="pre">set_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">selected</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.set_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: set the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.set_value_by_label"> <span class="sig-name descname"><span class="pre">set_value_by_label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.set_value_by_label" title="Permalink to this definition">¶</a></dt> <dd><p>Set the value of control by item labels.</p> <p>value is expected to be an iterable of strings that are substrings of the item labels that should be selected. Before substring matching is performed, the original label text is whitespace-compressed (consecutive whitespace characters are converted to a single space character) and leading and trailing whitespace is stripped. Ambiguous labels: it will not complain as long as all ambiguous labels share the same item name (e.g. OPTION value).</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.toggle"> <span class="sig-name descname"><span class="pre">toggle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.toggle" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: given a name or label and optional disambiguating index nr, toggle the matching item’s selection.</p> <p>Selecting items follows the behavior described in the docstring of the ‘get’ method.</p> <p>if the item is disabled, or this control is disabled or readonly, raise AttributeError.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.SelectControl.toggle_single"> <span class="sig-name descname"><span class="pre">toggle_single</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">by_label</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.SelectControl.toggle_single" title="Permalink to this definition">¶</a></dt> <dd><p>Deprecated: toggle the selection of the single item in this control.</p> <p>Raises ItemCountError if the control does not contain only one item.</p> <p>by_label argument is ignored, and included only for backwards compatibility.</p> </dd></dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.SubmitControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">SubmitControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#SubmitControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.SubmitControl" title="Permalink to this definition">¶</a></dt> <dd><p>Covers:</p> <p>INPUT/SUBMIT BUTTON/SUBMIT</p> <dl class="field-list simple"> <dt class="field-odd">Members</dt> <dd class="field-odd"><p></p></dd> <dt class="field-even">Inherited-members</dt> <dd class="field-even"><p></p></dd> <dt class="field-odd">Show-inheritance</dt> <dd class="field-odd"><p></p></dd> </dl> </dd></dl> <dl class="py class"> <dt class="sig sig-object py" id="mechanize.ImageControl"> <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize.</span></span><span class="sig-name descname"><span class="pre">ImageControl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_form_controls.html#ImageControl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.ImageControl" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#mechanize.SubmitControl" title="mechanize._form_controls.SubmitControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize._form_controls.SubmitControl</span></code></a></p> <p>Covers:</p> <p>INPUT/IMAGE</p> <p>Coordinates are specified using one of the HTMLForm.click* methods.</p> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ImageControl.get_labels"> <span class="sig-name descname"><span class="pre">get_labels</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.ImageControl.get_labels" title="Permalink to this definition">¶</a></dt> <dd><p>Return all labels (Label instances) for this control.</p> <p>If the control was surrounded by a <label> tag, that will be the first label; all other labels, connected by ‘for’ and ‘id’, are in the order that appear in the HTML.</p> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="mechanize.ImageControl.pairs"> <span class="sig-name descname"><span class="pre">pairs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.ImageControl.pairs" title="Permalink to this definition">¶</a></dt> <dd><p>Return list of (key, value) pairs suitable for passing to urlencode.</p> </dd></dl> </dd></dl> </section> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h1 class="logo"><a href="index.html">mechanize</a></h1> <h3>Navigation</h3> <p class="caption" role="heading"><span class="caption-text">Table of Contents:</span></p> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="browser_api.html">Browser API</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="#">HTML Forms API</a></li> <li class="toctree-l1"><a class="reference internal" href="advanced.html">Advanced topics</a></li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="browser_api.html" title="previous chapter">Browser API</a></li> <li>Next: <a href="advanced.html" title="next chapter">Advanced topics</a></li> </ul></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="search.html" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> <input type="submit" value="Go" /> </form> </div> </div> <script>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> ©2021, Kovid Goyal. | Powered by <a href="http://sphinx-doc.org/">Sphinx 4.3.2</a> & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a> | <a href="_sources/forms_api.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>