⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module-webbrowser.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>11.1 webbrowser -- Convenient Web-browser controller</title>
<META NAME="description" CONTENT="11.1 webbrowser -- Convenient Web-browser controller">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-cgi.html" tppabs="http://www.python.org/doc/current/lib/module-cgi.html">
<LINK REL="previous" href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html">
<LINK REL="up" href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html">
<LINK REL="next" href="browser-controllers.html" tppabs="http://www.python.org/doc/current/lib/browser-controllers.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="browser-controllers.html" tppabs="http://www.python.org/doc/current/lib/browser-controllers.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html">11. Internet Protocols and</A>
<b class="navlabel">Up:</b> <a class="sectref" href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html">11. Internet Protocols and</A>
<b class="navlabel">Next:</b> <a class="sectref" href="browser-controllers.html" tppabs="http://www.python.org/doc/current/lib/browser-controllers.html">11.1.1 Browser Controller Objects</A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0013100000000000000000">
11.1 <tt class="module">webbrowser</tt> --
         Convenient Web-browser controller</A>
</H1>

<P>


<P>
The <tt class="module">webbrowser</tt> module provides a very high-level interface to
allow displaying Web-based documents to users.  The controller objects
are easy to use and are platform independent.

<P>
Under Unix, graphical browsers are preferred under X11, but text-mode
browsers will be used if graphical browsers are not available or an X11
display isn't available.  If text-mode browsers are used, the calling
process will block until the user exits the browser.

<P>
For non-Unix platforms, or when X11 browsers are available on
Unix, the controlling process will not wait for the user to finish
with the browser, but allow the browser to maintain its own window on
the display.

<P>
The following exception is defined:

<P>
<dl><dt><b><a name='l2h-1967'><tt class='exception'>Error</tt></a></b>
<dd>
  Exception raised when a browser control error occurs.
</dl>

<P>
The following functions are defined:

<P>
<dl><dt><b><a name='l2h-1968'><tt class='function'>open</tt></a></b> (<var>url</var><big>[</big><var>, new</var><big>]</big>)
<dd>
  Display <var>url</var> using the default browser.  If <var>new</var> is true,
  a new browser window is opened if possible.
</dl>

<P>
<dl><dt><b><a name='l2h-1969'><tt class='function'>open_new</tt></a></b> (<var>url</var>)
<dd>
  Open <var>url</var> in a new window of the default browser, if possible,
  otherwise, open <var>url</var> in the only browser window.
</dl>

<P>
<dl><dt><b><a name='l2h-1970'><tt class='function'>get</tt></a></b> (<big>[</big><var>name</var><big>]</big>)
<dd>
  Return a controller object for the browser type <var>name</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-1971'><tt class='function'>register</tt></a></b> (<var>name, constructor</var><big>[</big><var>, controller</var><big>]</big>)
<dd>
  Register the browser type <var>name</var>.  Once a browser type is
  registered, the <tt class="function">get()</tt> function can return a controller
  for that browser type.  If <var>instance</var> is not provided, or is
  <code>None</code>, <var>constructor</var> will be called without parameters to
  create an instance when needed.  If <var>instance</var> is provided,
  <var>constructor</var> will never be called, and may be <code>None</code>.
</dl>

<P>
Several browser types are defined.  This table gives the type names
that may be passed to the <tt class="function">get()</tt> function and the names of
the implementation classes, all defined in this module.

<P>
<table border align="center" style="border-collapse: collapse">
  <thead>
    <tr>
      <th align="left"><b>Type Name</b>&nbsp;</th>
      <th align="left"><b>Class Name</b>&nbsp;</th>
      <th align="center"><b>Notes</b>&nbsp;</th>
    </thead>
  <tbody valign='baseline'>
    <tr><td align="left" valign="baseline"><code>'netscape'</code></td>
        <td align="left"><tt class="class">Netscape</tt></td>
        <td align="center">&nbsp;</td>
    <tr><td align="left" valign="baseline"><code>'kfm'</code></td>
        <td align="left"><tt class="class">Konquerer</tt></td>
        <td align="center">(1)</td>
    <tr><td align="left" valign="baseline"><code>'grail'</code></td>
        <td align="left"><tt class="class">Grail</tt></td>
        <td align="center">&nbsp;</td>
    <tr><td align="left" valign="baseline"><code>'windows-default'</code></td>
        <td align="left"><tt class="class">WindowsDefault</tt></td>
        <td align="center">(2)</td>
    <tr><td align="left" valign="baseline"><code>'internet-config'</code></td>
        <td align="left"><tt class="class">InternetConfig</tt></td>
        <td align="center">(3)</td>
    <tr><td align="left" valign="baseline"><code>'command-line'</code></td>
        <td align="left"><tt class="class">CommandLineBrowser</tt></td>
        <td align="center">&nbsp;</td></tbody>
</table>

<P>
Notes:

<P>
<DL>
<DT><STRONG>(1)</STRONG></DT>
<DD>``Konquerer'' is the file manager for the KDE desktop environment for
UNIX, and only makes sense to use if KDE is running.  Some way of
reliably detecting KDE would be nice; the <a class="envvar" name='l2h-1972'>$KDEDIR</a> variable is
not sufficient.

<P>
</DD>
<DT><STRONG>(2)</STRONG></DT>
<DD>Only on Windows platforms; requires the common
extension modules <tt class="module">win32api</tt> and <tt class="module">win32con</tt>.

<P>
</DD>
<DT><STRONG>(3)</STRONG></DT>
<DD>Only on MacOS platforms; requires the standard MacPython <tt class="module">ic</tt>
module, described in the <em class='citetitle'><a
 href="javascript:if(confirm('http://www.python.org/doc/current/mac/module-ic.html  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.python.org/doc/current/mac/module-ic.html'" tppabs="http://www.python.org/doc/current/mac/module-ic.html"
 title='Macintosh
Library Modules'
 >Macintosh
Library Modules</a></em> manual.
</DD>
</DL>

<P>

<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html3758"
  href="browser-controllers.html" tppabs="http://www.python.org/doc/current/lib/browser-controllers.html">11.1.1 Browser Controller Objects </A>
</UL>
<!--End of Table of Child-Links-->

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="browser-controllers.html" tppabs="http://www.python.org/doc/current/lib/browser-controllers.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html">11. Internet Protocols and</A>
<b class="navlabel">Up:</b> <a class="sectref" href="internet.html" tppabs="http://www.python.org/doc/current/lib/internet.html">11. Internet Protocols and</A>
<b class="navlabel">Next:</b> <a class="sectref" href="browser-controllers.html" tppabs="http://www.python.org/doc/current/lib/browser-controllers.html">11.1.1 Browser Controller Objects</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -