ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
ActivePython 2.4
Python Documentation
Library Reference
11. Internet Protocols and Support
11.1 webbrowser -- Convenient Web-browser controller
11.1.1 Browser Controller Objects
11.2 cgi -- Common Gateway Interface support.
11.3 cgitb -- Traceback manager for CGI scripts
11.4 urllib -- Open arbitrary resources by URL
11.5 urllib2 -- extensible library for opening URLs
11.6 httplib -- HTTP protocol client
11.7 ftplib -- FTP protocol client
11.8 gopherlib -- Gopher protocol client
11.9 poplib -- POP3 protocol client
11.10 imaplib -- IMAP4 protocol client
11.11 nntplib -- NNTP protocol client
11.12 smtplib -- SMTP protocol client
11.13 smtpd -- SMTP Server
11.14 telnetlib -- Telnet client
11.15 urlparse -- Parse URLs into components
11.16 SocketServer -- A framework for network servers
11.17 BaseHTTPServer -- Basic HTTP server
11.18 SimpleHTTPServer -- Simple HTTP request handler
11.19 CGIHTTPServer -- CGI-capable HTTP request handler
11.20 cookielib -- Cookie handling for HTTP clients
11.21 Cookie -- HTTP state management
11.22 xmlrpclib -- XML-RPC client access
11.23 SimpleXMLRPCServer -- Basic XML-RPC server
11.24 DocXMLRPCServer -- Self-documenting XML-RPC server
11.25 asyncore -- Asynchronous socket handler
11.26 asynchat -- Asynchronous socket command/response handler

MyASPN >> Reference >> ActivePython 2.4 >> Python Documentation >> Library Reference >> 11. Internet Protocols and Support
ActivePython 2.4 documentation

11.1 webbrowser -- Convenient Web-browser controller

The webbrowser 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. Under most circumstances, simply calling the open() function from this module will do the right thing.

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.

Under Unix, if the environment variable BROWSER exists, it is interpreted to override the platform default list of browsers, as a colon-separated list of browsers to try in order. When the value of a list part contains the string %s, then it is interpreted as a literal browser command line to be used with the argument URL substituted for the %s; if the part does not contain %s, it is simply interpreted as the name of the browser to launch.

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.

The following exception is defined:

exception Error
Exception raised when a browser control error occurs.

The following functions are defined:

open( url[, new=0][, autoraise=1])
Display url using the default browser. If new is true, a new browser window is opened if possible. If autoraise is true, the window is raised if possible (note that under many window managers this will occur regardless of the setting of this variable).

open_new( url)
Open url in a new window of the default browser, if possible, otherwise, open url in the only browser window.

get( [name])
Return a controller object for the browser type name. If name is empty, return a controller for a default browser appropriate to the caller's environment.

register( name, constructor[, instance])
Register the browser type name. Once a browser type is registered, the get() function can return a controller for that browser type. If instance is not provided, or is None, constructor will be called without parameters to create an instance when needed. If instance is provided, constructor will never be called, and may be None.

This entry point is only useful if you plan to either set the BROWSER variable or call get with a nonempty argument matching the name of a handler you declare.

A number of browser types are predefined. This table gives the type names that may be passed to the get() function and the corresponding instantiations for the controller classes, all defined in this module.

Type Name Class Name Notes
'mozilla' Netscape('mozilla')
'netscape' Netscape('netscape')
'mosaic' GenericBrowser('mosaic %s &')
'kfm' Konqueror() (1)
'grail' Grail()
'links' GenericBrowser('links %s')
'lynx' GenericBrowser('lynx %s')
'w3m' GenericBrowser('w3m %s')
'windows-default' WindowsDefault (2)
'internet-config' InternetConfig (3)

Notes:

(1)
``Konqueror'' 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 KDEDIR variable is not sufficient. Note also that the name ``kfm'' is used even when using the konqueror command with KDE 2 -- the implementation selects the best strategy for running Konqueror.

(2)
Only on Windows platforms; requires the common extension modules win32api and win32con.

(3)
Only on MacOS platforms; requires the standard MacPython ic module, described in the Macintosh Library Modules manual.



See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved