%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/doc/python3-mechanize/html/
Upload File :
Create Path :
Current File : //usr/share/doc/python3-mechanize/html/browser_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>Browser API &#8212; 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="HTML Forms API" href="forms_api.html" />
    <link rel="prev" title="Frequently Asked Questions" href="faq.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="module-mechanize._mechanize">
<span id="id1"></span><span id="browser-api"></span><h1><a class="toc-backref" href="#id2">Browser API</a><a class="headerlink" href="#module-mechanize._mechanize" title="Permalink to this headline">¶</a></h1>
<p>API documentation for the mechanize <a class="reference internal" href="#mechanize.Browser" title="mechanize._mechanize.Browser"><code class="xref py py-class docutils literal notranslate"><span class="pre">Browser</span></code></a> object.
You can create a mechanize <a class="reference internal" href="#mechanize.Browser" title="mechanize._mechanize.Browser"><code class="xref py py-class docutils literal notranslate"><span class="pre">Browser</span></code></a> instance as:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">mechanize</span> <span class="kn">import</span> <span class="n">Browser</span>
<span class="n">br</span> <span class="o">=</span> <span class="n">Browser</span><span class="p">()</span>
</pre></div>
</div>
<div class="contents topic" id="contents">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#module-mechanize._mechanize" id="id2">Browser API</a></p>
<ul>
<li><p><a class="reference internal" href="#the-browser" id="id3">The Browser</a></p></li>
<li><p><a class="reference internal" href="#the-request" id="id4">The Request</a></p></li>
<li><p><a class="reference internal" href="#the-response" id="id5">The Response</a></p></li>
<li><p><a class="reference internal" href="#miscellaneous" id="id6">Miscellaneous</a></p></li>
</ul>
</li>
</ul>
</div>
<section id="the-browser">
<h2><a class="toc-backref" href="#id3">The Browser</a><a class="headerlink" href="#the-browser" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="mechanize.Browser">
<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">Browser</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">history=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">request_class=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">content_parser=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factory_class=&lt;class</span> <span class="pre">'mechanize._html.Factory'&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_xhtml=False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser" title="Permalink to this definition">¶</a></dt>
<dd><p>Browser-like class with support for history, forms and links.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">BrowserStateError</span></code> is raised whenever the browser is in the wrong
state to complete the requested operation - e.g., when <a class="reference internal" href="#mechanize.Browser.back" title="mechanize.Browser.back"><code class="xref py py-meth docutils literal notranslate"><span class="pre">back()</span></code></a> is
called when the browser history is empty, or when <a class="reference internal" href="#mechanize.Browser.follow_link" title="mechanize.Browser.follow_link"><code class="xref py py-meth docutils literal notranslate"><span class="pre">follow_link()</span></code></a> is
called when the current response does not contain HTML data.</p>
<p>Public attributes:</p>
<p>request: current request (<a class="reference internal" href="#mechanize.Request" title="mechanize.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Request</span></code></a>)</p>
<p>form: currently selected form (see <a class="reference internal" href="#mechanize.Browser.select_form" title="mechanize.Browser.select_form"><code class="xref py py-meth docutils literal notranslate"><span class="pre">select_form()</span></code></a>)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>history</strong> – object implementing the <a class="reference internal" href="#mechanize.History" title="mechanize.History"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.History</span></code></a>
interface.  Note this interface is still experimental
and may change in future. This object is owned
by the browser instance and must not be shared
among browsers.</p></li>
<li><p><strong>request_class</strong> – Request class to use. Defaults to
<a class="reference internal" href="#mechanize.Request" title="mechanize.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Request</span></code></a></p></li>
<li><p><strong>content_parser</strong> – A function that is responsible for parsing
received html/xhtml content. See the builtin
<a class="reference internal" href="#mechanize._html.content_parser" title="mechanize._html.content_parser"><code class="xref py py-func docutils literal notranslate"><span class="pre">mechanize._html.content_parser()</span></code></a> function for details
on the interface this function must support.</p></li>
<li><p><strong>factory_class</strong> – HTML Factory class to use. Defaults to
<code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Factory</span></code></p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.add_client_certificate">
<span class="sig-name descname"><span class="pre">add_client_certificate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">key_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cert_file</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.add_client_certificate" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an SSL client certificate, for HTTPS client auth.</p>
<p>key_file and cert_file must be filenames of the key and certificate
files, in PEM format.  You can use e.g. OpenSSL to convert a p12 (PKCS
12) file to PEM format:</p>
<p>openssl pkcs12 -clcerts -nokeys -in cert.p12 -out cert.pem
openssl pkcs12 -nocerts -in cert.p12 -out key.pem</p>
<p>Note that client certificate password input is very inflexible ATM.  At
the moment this seems to be console only, which is presumably the
default behaviour of libopenssl.  In future mechanize may support
third-party libraries that (I assume) allow more options here.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.back">
<span class="sig-name descname"><span class="pre">back</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.back"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.back" title="Permalink to this definition">¶</a></dt>
<dd><p>Go back n steps in history, and return response object.</p>
<p>n: go back this number of steps (default 1 step)</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.click">
<span class="sig-name descname"><span class="pre">click</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwds</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.click"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.click" title="Permalink to this definition">¶</a></dt>
<dd><p>See <a class="reference internal" href="forms_api.html#mechanize.HTMLForm.click" title="mechanize.HTMLForm.click"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.HTMLForm.click()</span></code></a> for documentation.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.click_link">
<span class="sig-name descname"><span class="pre">click_link</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link</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="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwds</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.click_link"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.click_link" title="Permalink to this definition">¶</a></dt>
<dd><p>Find a link and return a Request object for it.</p>
<p>Arguments are as for <a class="reference internal" href="#mechanize.Browser.find_link" title="mechanize.Browser.find_link"><code class="xref py py-meth docutils literal notranslate"><span class="pre">find_link()</span></code></a>, except that a link may be
supplied as the first argument.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="mechanize.Browser.cookiejar">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">cookiejar</span></span><a class="headerlink" href="#mechanize.Browser.cookiejar" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the current cookiejar (<code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.CookieJar</span></code>) or None</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.find_link">
<span class="sig-name descname"><span class="pre">find_link</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</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">text_regex</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">name_regex</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">url</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">url_regex</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">tag</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">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.find_link"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.find_link" title="Permalink to this definition">¶</a></dt>
<dd><p>Find a link in current page.</p>
<p>Links are returned as <a class="reference internal" href="#mechanize.Link" title="mechanize.Link"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Link</span></code></a> objects. Examples:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Return third link that .search()-matches the regexp &quot;python&quot; (by</span>
<span class="c1"># &quot;.search()-matches&quot;, I mean that the regular expression method</span>
<span class="c1"># .search() is used, rather than .match()).</span>
<span class="n">find_link</span><span class="p">(</span><span class="n">text_regex</span><span class="o">=</span><span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s2">&quot;python&quot;</span><span class="p">),</span> <span class="n">nr</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>

<span class="c1"># Return first http link in the current page that points to</span>
<span class="c1"># somewhere on python.org whose link text (after tags have been</span>
<span class="c1"># removed) is exactly &quot;monty python&quot;.</span>
<span class="n">find_link</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s2">&quot;monty python&quot;</span><span class="p">,</span>
        <span class="n">url_regex</span><span class="o">=</span><span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s2">&quot;http.*python.org&quot;</span><span class="p">))</span>

<span class="c1"># Return first link with exactly three HTML attributes.</span>
<span class="n">find_link</span><span class="p">(</span><span class="n">predicate</span><span class="o">=</span><span class="k">lambda</span> <span class="n">link</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">link</span><span class="o">.</span><span class="n">attrs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>Links include anchors <cite>&lt;a&gt;</cite>, image maps <cite>&lt;area&gt;</cite>, and frames
<cite>&lt;iframe&gt;</cite>.</p>
<p>All arguments must be passed by keyword, not position.  Zero or more
arguments may be supplied.  In order to find a link, all arguments
supplied must match.</p>
<p>If a matching link is not found, <code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.LinkNotFoundError</span></code>
is raised.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>text</strong> – link text between link tags: e.g. &lt;a href=”blah”&gt;this
bit&lt;/a&gt; with whitespace compressed.</p></li>
<li><p><strong>text_regex</strong> – link text between tag (as defined above) must match
the regular expression object or regular expression string passed
as this argument, if supplied</p></li>
<li><p><strong>name</strong> – as for text and text_regex, but matched
against the name HTML attribute of the link tag</p></li>
<li><p><strong>url</strong> – as for text and text_regex, but matched against the
URL of the link tag (note this matches against Link.url, which is a
relative or absolute URL according to how it was written in the
HTML)</p></li>
<li><p><strong>tag</strong> – element name of opening tag, e.g. “a”</p></li>
<li><p><strong>predicate</strong> – a function taking a Link object as its single
argument, returning a boolean result, indicating whether the links</p></li>
<li><p><strong>nr</strong> – matches the nth link that matches all other
criteria (default 0)</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.follow_link">
<span class="sig-name descname"><span class="pre">follow_link</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">link</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="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwds</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.follow_link"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.follow_link" title="Permalink to this definition">¶</a></dt>
<dd><p>Find a link and <a class="reference internal" href="#mechanize.Browser.open" title="mechanize.Browser.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">open()</span></code></a> it.</p>
<p>Arguments are as for <a class="reference internal" href="#mechanize.Browser.click_link" title="mechanize.Browser.click_link"><code class="xref py py-meth docutils literal notranslate"><span class="pre">click_link()</span></code></a>.</p>
<p>Return value is same as for <a class="reference internal" href="#mechanize.Browser.open" title="mechanize.Browser.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">open()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.forms">
<span class="sig-name descname"><span class="pre">forms</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.forms"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.forms" title="Permalink to this definition">¶</a></dt>
<dd><p>Return iterable over forms.</p>
<p>The returned form objects implement the <a class="reference internal" href="forms_api.html#mechanize.HTMLForm" title="mechanize.HTMLForm"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.HTMLForm</span></code></a>
interface.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.geturl">
<span class="sig-name descname"><span class="pre">geturl</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.geturl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.geturl" title="Permalink to this definition">¶</a></dt>
<dd><p>Get URL of current document.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.global_form">
<span class="sig-name descname"><span class="pre">global_form</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.global_form"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.global_form" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the global form object, or None if the factory implementation
did not supply one.</p>
<p>The “global” form object contains all controls that are not descendants
of any FORM element.</p>
<p>The returned form object implements the <a class="reference internal" href="forms_api.html#mechanize.HTMLForm" title="mechanize.HTMLForm"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.HTMLForm</span></code></a>
interface.</p>
<p>This is a separate method since the global form is not regarded as part
of the sequence of forms in the document – mostly for
backwards-compatibility.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.links">
<span class="sig-name descname"><span class="pre">links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwds</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.links"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.links" title="Permalink to this definition">¶</a></dt>
<dd><p>Return iterable over links (<a class="reference internal" href="#mechanize.Link" title="mechanize.Link"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Link</span></code></a> objects).</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.open">
<span class="sig-name descname"><span class="pre">open</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url_or_request</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout=&lt;object</span> <span class="pre">object&gt;</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.open"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.open" title="Permalink to this definition">¶</a></dt>
<dd><p>Open a URL. Loads the page so that you can subsequently use
<a class="reference internal" href="#mechanize.Browser.forms" title="mechanize.Browser.forms"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forms()</span></code></a>, <a class="reference internal" href="#mechanize.Browser.links" title="mechanize.Browser.links"><code class="xref py py-meth docutils literal notranslate"><span class="pre">links()</span></code></a>, etc. on it.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>url_or_request</strong> – Either a URL or a <a class="reference internal" href="#mechanize.Request" title="mechanize.Request"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Request</span></code></a></p></li>
<li><p><strong>data</strong> (<em>dict</em>) – data to send with a POST request</p></li>
<li><p><strong>timeout</strong> – Timeout in seconds</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A <code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.Response</span></code> object</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.open_novisit">
<span class="sig-name descname"><span class="pre">open_novisit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url_or_request</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout=&lt;object</span> <span class="pre">object&gt;</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.open_novisit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.open_novisit" title="Permalink to this definition">¶</a></dt>
<dd><p>Open a URL without visiting it.</p>
<p>Browser state (including request, response, history, forms and links)
is left unchanged by calling this function.</p>
<p>The interface is the same as for <a class="reference internal" href="#mechanize.Browser.open" title="mechanize.Browser.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">open()</span></code></a>.</p>
<p>This is useful for things like fetching images.</p>
<p>See also <a class="reference internal" href="#mechanize.Browser.retrieve" title="mechanize.Browser.retrieve"><code class="xref py py-meth docutils literal notranslate"><span class="pre">retrieve()</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.reload">
<span class="sig-name descname"><span class="pre">reload</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.reload"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.reload" title="Permalink to this definition">¶</a></dt>
<dd><p>Reload current document, and return response object.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.response">
<span class="sig-name descname"><span class="pre">response</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.response"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.response" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a copy of the current response.</p>
<p>The returned object has the same interface as the object returned by
<a class="reference internal" href="#mechanize.Browser.open" title="mechanize.Browser.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">open()</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.retrieve">
<span class="sig-name descname"><span class="pre">retrieve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fullurl</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reporthook=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout=&lt;object</span> <span class="pre">object&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">open=&lt;built-in</span> <span class="pre">function</span> <span class="pre">open&gt;</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.retrieve" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns (filename, headers).</p>
<p>For remote objects, the default filename will refer to a temporary
file.  Temporary files are removed when the OpenerDirector.close()
method is called.</p>
<p>For file: URLs, at present the returned filename is None.  This may
change in future.</p>
<p>If the actual number of bytes read is less than indicated by the
Content-Length header, raises ContentTooShortError (a URLError
subclass).  The exception’s .result attribute contains the (filename,
headers) that would have been returned.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.select_form">
<span class="sig-name descname"><span class="pre">select_form</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">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="o"><span class="pre">**</span></span><span class="n"><span class="pre">attrs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.select_form"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.select_form" title="Permalink to this definition">¶</a></dt>
<dd><p>Select an HTML form for input.</p>
<p>This is a bit like giving a form the “input focus” in a browser.</p>
<p>If a form is selected, the Browser object supports the HTMLForm
interface, so you can call methods like <code class="xref py py-meth docutils literal notranslate"><span class="pre">set_value()</span></code>,
<code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code>, and <a class="reference internal" href="#mechanize.Browser.click" title="mechanize.Browser.click"><code class="xref py py-meth docutils literal notranslate"><span class="pre">click()</span></code></a>.</p>
<p>Another way to select a form is to assign to the .form attribute.  The
form assigned should be one of the objects returned by the
<a class="reference internal" href="#mechanize.Browser.forms" title="mechanize.Browser.forms"><code class="xref py py-meth docutils literal notranslate"><span class="pre">forms()</span></code></a> method.</p>
<p>If no matching form is found,
<code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.FormNotFoundError</span></code> is raised.</p>
<p>If <cite>name</cite> is specified, then the form must have the indicated name.</p>
<p>If <cite>predicate</cite> is specified, then the form must match that function.
The predicate function is passed the <a class="reference internal" href="forms_api.html#mechanize.HTMLForm" title="mechanize.HTMLForm"><code class="xref py py-class docutils literal notranslate"><span class="pre">mechanize.HTMLForm</span></code></a> as its
single argument, and should return a boolean value indicating whether
the form matched.</p>
<p><cite>nr</cite>, if supplied, is the sequence number of the form (where 0 is the
first).  Note that control 0 is the first form matching all the other
arguments (if supplied); it is not necessarily the first control in the
form.  The “global form” (consisting of all form controls not contained
in any FORM element) is considered not to be part of this sequence and
to have no name, so will not be matched unless both name and nr are
None.</p>
<p>You can also match on any HTML attribute of the <cite>&lt;form&gt;</cite> tag by passing
in the attribute name and value as keyword arguments. To convert HTML
attributes into syntactically valid python keyword arguments, the
following simple rule is used. The python keyword argument name is
converted to an HTML attribute name by: Replacing all underscores with
hyphens and removing any trailing underscores. You can pass in strings,
functions or regular expression objects as the values to match. For
example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Match form with the exact action specified</span>
<span class="n">br</span><span class="o">.</span><span class="n">select_form</span><span class="p">(</span><span class="n">action</span><span class="o">=</span><span class="s1">&#39;http://foo.com/submit.php&#39;</span><span class="p">)</span>
<span class="c1"># Match form with a class attribute that contains &#39;login&#39;</span>
<span class="n">br</span><span class="o">.</span><span class="n">select_form</span><span class="p">(</span><span class="n">class_</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="s1">&#39;login&#39;</span> <span class="ow">in</span> <span class="n">x</span><span class="p">)</span>
<span class="c1"># Match form with a data-form-type attribute that matches a regex</span>
<span class="n">br</span><span class="o">.</span><span class="n">select_form</span><span class="p">(</span><span class="n">data_form_type</span><span class="o">=</span><span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;a|b&#39;</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_ca_data">
<span class="sig-name descname"><span class="pre">set_ca_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cafile</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">capath</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">cadata</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">context</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.Browser.set_ca_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the SSL Context used for connecting to SSL servers.</p>
<p>This method accepts the same arguments as the
<code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.load_verify_locations()</span></code> method from the
python standard library. You can also pass a pre-built context via the
<cite>context</cite> keyword argument. Note that to use this feature, you must be
using python &gt;= 2.7.9. In addition you can directly pass in
a pre-built <code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLContext</span></code> as the <cite>context</cite> argument.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_client_cert_manager">
<span class="sig-name descname"><span class="pre">set_client_cert_manager</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cert_manager</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_client_cert_manager" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a mechanize.HTTPClientCertMgr, or None.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_cookie">
<span class="sig-name descname"><span class="pre">set_cookie</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cookie_string</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.set_cookie"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.set_cookie" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a cookie.</p>
<p>Note that it is NOT necessary to call this method under ordinary
circumstances: cookie handling is normally entirely automatic.  The
intended use case is rather to simulate the setting of a cookie by
client script in a web page (e.g. JavaScript).  In that case, use of
this method is necessary because mechanize currently does not support
JavaScript, VBScript, etc.</p>
<p>The cookie is added in the same way as if it had arrived with the
current response, as a result of the current request.  This means that,
for example, if it is not appropriate to set the cookie based on the
current request, no cookie will be set.</p>
<p>The cookie will be returned automatically with subsequent responses
made by the Browser instance whenever that’s appropriate.</p>
<p>cookie_string should be a valid value of the Set-Cookie header.</p>
<p>For example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">browser</span><span class="o">.</span><span class="n">set_cookie</span><span class="p">(</span>
    <span class="s2">&quot;sid=abcdef; expires=Wednesday, 09-Nov-06 23:12:40 GMT&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Currently, this method does not allow for adding RFC 2986 cookies.
This limitation will be lifted if anybody requests it.</p>
<p>See also <a class="reference internal" href="#mechanize.Browser.set_simple_cookie" title="mechanize.Browser.set_simple_cookie"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_simple_cookie()</span></code></a> for an easier way to set cookies
without needing to create a Set-Cookie header string.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_cookiejar">
<span class="sig-name descname"><span class="pre">set_cookiejar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cookiejar</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_cookiejar" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a mechanize.CookieJar, or None.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_debug_http">
<span class="sig-name descname"><span class="pre">set_debug_http</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_debug_http" title="Permalink to this definition">¶</a></dt>
<dd><p>Print HTTP headers to sys.stdout.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_debug_redirects">
<span class="sig-name descname"><span class="pre">set_debug_redirects</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_debug_redirects" title="Permalink to this definition">¶</a></dt>
<dd><p>Log information about HTTP redirects (including refreshes).</p>
<p>Logging is performed using module logging.  The logger name is
<cite>“mechanize.http_redirects”</cite>.  To actually print some debug output,
eg:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">logging</span>
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">&quot;mechanize.http_redirects&quot;</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">))</span>
<span class="n">logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
</pre></div>
</div>
<p>Other logger names relevant to this module:</p>
<ul class="simple">
<li><p><cite>mechanize.http_responses</cite></p></li>
<li><p><cite>mechanize.cookies</cite></p></li>
</ul>
<p>To turn on everything:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">logging</span>
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">&quot;mechanize&quot;</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">))</span>
<span class="n">logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_debug_responses">
<span class="sig-name descname"><span class="pre">set_debug_responses</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_debug_responses" title="Permalink to this definition">¶</a></dt>
<dd><p>Log HTTP response bodies.</p>
<p>See <a class="reference internal" href="#mechanize.Browser.set_debug_redirects" title="mechanize.Browser.set_debug_redirects"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_debug_redirects()</span></code></a> for details of logging.</p>
<p>Response objects may be .seek()able if this is set (currently returned
responses are, raised HTTPError exception responses are not).</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_handle_equiv">
<span class="sig-name descname"><span class="pre">set_handle_equiv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">head_parser_class</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.Browser.set_handle_equiv" title="Permalink to this definition">¶</a></dt>
<dd><p>Set whether to treat HTML http-equiv headers like HTTP headers.</p>
<p>Response objects may be .seek()able if this is set (currently returned
responses are, raised HTTPError exception responses are not).</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_handle_gzip">
<span class="sig-name descname"><span class="pre">set_handle_gzip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_handle_gzip" title="Permalink to this definition">¶</a></dt>
<dd><p>Add header indicating to server that we handle gzip
content encoding. Note that if the server sends gzip’ed content,
it is handled automatically in any case, regardless of this setting.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_handle_redirect">
<span class="sig-name descname"><span class="pre">set_handle_redirect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_handle_redirect" title="Permalink to this definition">¶</a></dt>
<dd><p>Set whether to handle HTTP 30x redirections.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_handle_referer">
<span class="sig-name descname"><span class="pre">set_handle_referer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.set_handle_referer"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.set_handle_referer" title="Permalink to this definition">¶</a></dt>
<dd><p>Set whether to add Referer header to each request.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_handle_refresh">
<span class="sig-name descname"><span class="pre">set_handle_refresh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_time</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">honor_time</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_handle_refresh" title="Permalink to this definition">¶</a></dt>
<dd><p>Set whether to handle HTTP Refresh headers.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_handle_robots">
<span class="sig-name descname"><span class="pre">set_handle_robots</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_handle_robots" title="Permalink to this definition">¶</a></dt>
<dd><p>Set whether to observe rules from robots.txt.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_handled_schemes">
<span class="sig-name descname"><span class="pre">set_handled_schemes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">schemes</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_handled_schemes" title="Permalink to this definition">¶</a></dt>
<dd><p>Set sequence of URL scheme (protocol) strings.</p>
<p>For example: ua.set_handled_schemes([“http”, “ftp”])</p>
<p>If this fails (with ValueError) because you’ve passed an unknown
scheme, the set of handled schemes will not be changed.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_header">
<span class="sig-name descname"><span class="pre">set_header</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">header</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</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/_mechanize.html#Browser.set_header"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.set_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Convenience method to set a header value in <cite>self.addheaders</cite>
so that the header is sent out with all requests automatically.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>header</strong> – The header name, e.g. User-Agent</p></li>
<li><p><strong>value</strong> – The header value. If set to None the header is removed.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_html">
<span class="sig-name descname"><span class="pre">set_html</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">html</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">url</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'http://example.com/'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.set_html"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.set_html" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the response to dummy with given HTML, and URL if given.</p>
<p>Allows you to then parse that HTML, especially to extract forms
information. If no URL was given then the default is “example.com”.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_password_manager">
<span class="sig-name descname"><span class="pre">set_password_manager</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">password_manager</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_password_manager" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a mechanize.HTTPPasswordMgrWithDefaultRealm, or None.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_proxies">
<span class="sig-name descname"><span class="pre">set_proxies</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">proxies</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">proxy_bypass</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.Browser.set_proxies" title="Permalink to this definition">¶</a></dt>
<dd><p>Configure proxy settings.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>proxies</strong> – dictionary mapping URL scheme to proxy specification.
None means use the default system-specific settings.</p></li>
<li><p><strong>proxy_bypass</strong> – function taking hostname, returning whether proxy
should be used.  None means use the default system-specific settings.</p></li>
</ul>
</dd>
</dl>
<p>The default is to try to obtain proxy settings from the system (see the
documentation for urllib.urlopen for information about the
system-specific methods used – note that’s urllib, not urllib2).</p>
<p>To avoid all use of proxies, pass an empty proxies dict.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ua</span> <span class="o">=</span> <span class="n">UserAgentBase</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">proxy_bypass</span><span class="p">(</span><span class="n">hostname</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">return</span> <span class="n">hostname</span> <span class="o">==</span> <span class="s2">&quot;noproxy.com&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ua</span><span class="o">.</span><span class="n">set_proxies</span><span class="p">(</span>
<span class="gp">... </span>    <span class="p">{</span><span class="s2">&quot;http&quot;</span><span class="p">:</span> <span class="s2">&quot;joe:password@myproxy.example.com:3128&quot;</span><span class="p">,</span>
<span class="gp">... </span>     <span class="s2">&quot;ftp&quot;</span><span class="p">:</span> <span class="s2">&quot;proxy.example.com&quot;</span><span class="p">},</span>
<span class="gp">... </span>    <span class="n">proxy_bypass</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_proxy_password_manager">
<span class="sig-name descname"><span class="pre">set_proxy_password_manager</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">password_manager</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_proxy_password_manager" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a mechanize.HTTPProxyPasswordMgr, or None.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_request_gzip">
<span class="sig-name descname"><span class="pre">set_request_gzip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Browser.set_request_gzip" title="Permalink to this definition">¶</a></dt>
<dd><p>Add header indicating to server that we handle gzip
content encoding. Note that if the server sends gzip’ed content,
it is handled automatically in any case, regardless of this setting.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_response">
<span class="sig-name descname"><span class="pre">set_response</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">response</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.set_response"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.set_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Replace current response with (a copy of) response.</p>
<p>response may be None.</p>
<p>This is intended mostly for HTML-preprocessing.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.set_simple_cookie">
<span class="sig-name descname"><span class="pre">set_simple_cookie</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">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">path</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'/'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.set_simple_cookie"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.set_simple_cookie" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to <a class="reference internal" href="#mechanize.Browser.set_cookie" title="mechanize.Browser.set_cookie"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_cookie()</span></code></a> except that instead of using a
cookie string, you simply specify the <cite>name</cite>, <cite>value</cite>, <cite>domain</cite>
and optionally the <cite>path</cite>.
The created cookie will never expire. For example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">browser</span><span class="o">.</span><span class="n">set_simple_cookie</span><span class="p">(</span><span class="s1">&#39;some_key&#39;</span><span class="p">,</span> <span class="s1">&#39;some_value&#39;</span><span class="p">,</span> <span class="s1">&#39;.example.com&#39;</span><span class="p">,</span>
                          <span class="n">path</span><span class="o">=</span><span class="s1">&#39;/some-page&#39;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.submit">
<span class="sig-name descname"><span class="pre">submit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwds</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.submit"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.submit" title="Permalink to this definition">¶</a></dt>
<dd><p>Submit current form.</p>
<p>Arguments are as for <a class="reference internal" href="forms_api.html#mechanize.HTMLForm.click" title="mechanize.HTMLForm.click"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mechanize.HTMLForm.click()</span></code></a>.</p>
<p>Return value is same as for <a class="reference internal" href="#mechanize.Browser.open" title="mechanize.Browser.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">open()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.title">
<span class="sig-name descname"><span class="pre">title</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.title"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.title" title="Permalink to this definition">¶</a></dt>
<dd><p>Return title, or None if there is no title element in the document.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.viewing_html">
<span class="sig-name descname"><span class="pre">viewing_html</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_mechanize.html#Browser.viewing_html"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.viewing_html" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the current response contains HTML data.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Browser.visit_response">
<span class="sig-name descname"><span class="pre">visit_response</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">response</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">request</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/_mechanize.html#Browser.visit_response"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Browser.visit_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Visit the response, as if it had been <a class="reference internal" href="#mechanize.Browser.open" title="mechanize.Browser.open"><code class="xref py py-meth docutils literal notranslate"><span class="pre">open()</span></code></a> ed.</p>
<p>Unlike <a class="reference internal" href="#mechanize.Browser.set_response" title="mechanize.Browser.set_response"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_response()</span></code></a>, this updates history rather than
replacing the current response.</p>
</dd></dl>

</dd></dl>

</section>
<section id="the-request">
<h2><a class="toc-backref" href="#id4">The Request</a><a class="headerlink" href="#the-request" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="mechanize.Request">
<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">Request</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">headers={}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">origin_req_host=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unverifiable=False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">visit=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout=&lt;object</span> <span class="pre">object&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method=None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_request.html#Request"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request" title="Permalink to this definition">¶</a></dt>
<dd><p>A request for some network resource. Note that if you specify the method as
‘GET’ and the data as a dict, then it will be automatically appended to the
URL. If you leave method as None, then the method will be auto-set to
POST and the data will become part of the POST request.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>url</strong> (<em>str</em>) – The URL to request</p></li>
<li><p><strong>data</strong> – Data to send with this request. Can be either a dictionary
which will be encoded and sent as application/x-www-form-urlencoded
data or a bytestring which will be sent as is. If you use a bytestring
you should also set the Content-Type header appropriately.</p></li>
<li><p><strong>headers</strong> (<em>dict</em>) – Headers to send with this request</p></li>
<li><p><strong>method</strong> (<em>str</em>) – Method to use for HTTP requests. If not specified
mechanize will choose GET or POST automatically as appropriate.</p></li>
<li><p><strong>timeout</strong> (<em>float</em>) – Timeout in seconds</p></li>
</ul>
</dd>
</dl>
<p>The remaining arguments are for internal use.</p>
<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.add_data">
<span class="sig-name descname"><span class="pre">add_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize.Request.add_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the data (a bytestring) to be sent with this request</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.add_header">
<span class="sig-name descname"><span class="pre">add_header</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val</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/_urllib2_fork.html#Request.add_header"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.add_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Add the specified header, replacing existing one, if needed. If val
is None, remove the header.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.add_unredirected_header">
<span class="sig-name descname"><span class="pre">add_unredirected_header</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.add_unredirected_header"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.add_unredirected_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#mechanize.Request.add_header" title="mechanize.Request.add_header"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_header()</span></code></a> except that this header will not
be sent for redirected requests.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.get_data">
<span class="sig-name descname"><span class="pre">get_data</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.get_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>The data to be sent with this request</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.get_header">
<span class="sig-name descname"><span class="pre">get_header</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">header_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</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/_urllib2_fork.html#Request.get_header"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.get_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the value of the specified header. If absent, return <cite>default</cite></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.get_method">
<span class="sig-name descname"><span class="pre">get_method</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.get_method"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.get_method" title="Permalink to this definition">¶</a></dt>
<dd><p>The method used for HTTP requests</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.has_data">
<span class="sig-name descname"><span class="pre">has_data</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.has_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.has_data" title="Permalink to this definition">¶</a></dt>
<dd><p>True iff there is some data to be sent with this request</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.has_header">
<span class="sig-name descname"><span class="pre">has_header</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">header_name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.has_header"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.has_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the specified header is present</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.has_proxy">
<span class="sig-name descname"><span class="pre">has_proxy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.has_proxy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.has_proxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Private method.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.header_items">
<span class="sig-name descname"><span class="pre">header_items</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.header_items"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.header_items" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a copy of all headers for this request as a list of 2-tuples</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize.Request.set_data">
<span class="sig-name descname"><span class="pre">set_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_urllib2_fork.html#Request.set_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Request.set_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the data (a bytestring) to be sent with this request</p>
</dd></dl>

</dd></dl>

</section>
<section id="the-response">
<h2><a class="toc-backref" href="#id5">The Response</a><a class="headerlink" href="#the-response" title="Permalink to this headline">¶</a></h2>
<p>Response objects in mechanize are <cite>seek()</cite> able <code class="xref py py-class docutils literal notranslate"><span class="pre">file</span></code>-like objects that support
some additional methods, depending on the protocol used for the connection. The documentation
below is for HTTP(s) responses, as these are the most common.</p>
<p>Additional methods present for HTTP responses:</p>
<dl class="py class">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mechanize._mechanize.</span></span><span class="sig-name descname"><span class="pre">HTTPResponse</span></span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse" title="Permalink to this definition">¶</a></dt>
<dd><dl class="py attribute">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse.code">
<span class="sig-name descname"><span class="pre">code</span></span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse.code" title="Permalink to this definition">¶</a></dt>
<dd><p>The HTTP status code</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse.getcode">
<span class="sig-name descname"><span class="pre">getcode</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse.getcode" title="Permalink to this definition">¶</a></dt>
<dd><p>Return HTTP status code</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse.geturl">
<span class="sig-name descname"><span class="pre">geturl</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse.geturl" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the URL of the resource retrieved, commonly used to determine if
a redirect was followed</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse.get_all_header_names">
<span class="sig-name descname"><span class="pre">get_all_header_names</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">normalize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse.get_all_header_names" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of all headers names. When <cite>normalize</cite> is <cite>True</cite>, the
case of the header names is normalized.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse.get_all_header_values">
<span class="sig-name descname"><span class="pre">get_all_header_values</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">normalize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse.get_all_header_values" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of all values for the specified header <cite>name</cite> (which is
case-insensitive. Since headers in HTTP can be specified multiple
times, the returned value is always a list. See
<code class="xref py py-meth docutils literal notranslate"><span class="pre">rfc822.Message.getheaders()</span></code>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse.info">
<span class="sig-name descname"><span class="pre">info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse.info" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the headers of the response as a <code class="xref py py-class docutils literal notranslate"><span class="pre">rfc822.Message</span></code>
instance.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="mechanize._mechanize.HTTPResponse.__getitem__">
<span class="sig-name descname"><span class="pre">__getitem__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">header_name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mechanize._mechanize.HTTPResponse.__getitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <em>last</em> HTTP Header matching the specified name as string.
mechanize Response object act like dictionaries for convenient access
to header values. For example: <code class="code docutils literal notranslate"><span class="pre">response['Date']</span></code>. You can access
header values using the header names, case-insensitively. Note that
when more than one header with the same name is present, only the value
of the last header is returned, use <a class="reference internal" href="#mechanize._mechanize.HTTPResponse.get_all_header_values" title="mechanize._mechanize.HTTPResponse.get_all_header_values"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_all_header_values()</span></code></a> to
get the values of all headers.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">get(header_name,</span> <span class="pre">default=None):</span></span></dt>
<dd><p>Return the header value for the specified <cite>header_name</cite> or <cite>default</cite> if
the header is not present. See <a class="reference internal" href="#mechanize._mechanize.HTTPResponse.__getitem__" title="mechanize._mechanize.HTTPResponse.__getitem__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__getitem__()</span></code></a>.</p>
</dd></dl>

</dd></dl>

</section>
<section id="miscellaneous">
<h2><a class="toc-backref" href="#id6">Miscellaneous</a><a class="headerlink" href="#miscellaneous" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="mechanize.Link">
<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">Link</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">base_url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">text</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tag</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attrs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_html.html#Link"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.Link" title="Permalink to this definition">¶</a></dt>
<dd><p>A link in a HTML document</p>
<dl class="field-list simple">
<dt class="field-odd">Variables</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>absolute_url</strong> – The absolutized link URL</p></li>
<li><p><strong>url</strong> – The link URL</p></li>
<li><p><strong>base_url</strong> – The base URL against which this link is resolved</p></li>
<li><p><strong>text</strong> – The link text</p></li>
<li><p><strong>tag</strong> – The link tag name</p></li>
<li><p><strong>attrs</strong> – The tag attributes</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="mechanize.History">
<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">History</span></span><a class="reference internal" href="_modules/mechanize/_mechanize.html#History"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize.History" title="Permalink to this definition">¶</a></dt>
<dd><p>Though this will become public, the implied interface is not yet stable.</p>
</dd></dl>

<span class="target" id="module-mechanize._html"></span><dl class="py function">
<dt class="sig sig-object py" id="mechanize._html.content_parser">
<span class="sig-prename descclassname"><span class="pre">mechanize._html.</span></span><span class="sig-name descname"><span class="pre">content_parser</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">url</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">response_info</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">transport_encoding</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">default_encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'utf-8'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">is_html</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mechanize/_html.html#content_parser"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mechanize._html.content_parser" title="Permalink to this definition">¶</a></dt>
<dd><p>Parse data (a bytes object) into an etree representation such as
<code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code> or <cite>lxml.etree</cite></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>bytes</em>) – The data to parse</p></li>
<li><p><strong>url</strong> – The URL of the document being parsed or None</p></li>
<li><p><strong>response_info</strong> – Information about the document
(contains all HTTP headers as <code class="xref py py-class docutils literal notranslate"><span class="pre">HTTPMessage</span></code>)</p></li>
<li><p><strong>transport_encoding</strong> – The character encoding for the document being
parsed as specified in the HTTP headers or None.</p></li>
<li><p><strong>default_encoding</strong> – The character encoding to use if no encoding
could be detected and no transport_encoding is specified</p></li>
<li><p><strong>is_html</strong> – If the document is to be parsed as HTML.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</section>
</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 current"><a class="current reference internal" href="#">Browser API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#the-browser">The Browser</a></li>
<li class="toctree-l2"><a class="reference internal" href="#the-request">The Request</a></li>
<li class="toctree-l2"><a class="reference internal" href="#the-response">The Response</a></li>
<li class="toctree-l2"><a class="reference internal" href="#miscellaneous">Miscellaneous</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="forms_api.html">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="faq.html" title="previous chapter">Frequently Asked Questions</a></li>
      <li>Next: <a href="forms_api.html" title="next chapter">HTML Forms API</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">
      &copy;2021, Kovid Goyal.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 4.3.2</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/browser_api.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>

Zerion Mini Shell 1.0