7.23 The webbrowser Module
(New in 2.0) The webbrowser module provides a basic interface to the system's
standard web browser. It provides an open function,
which takes a filename or a URL, and displays it in the browser. If
you call open again, it attempts to display the
new page in the same browser window. Example 7-41 demonstrates the webbrowser module.
Example 7-41. Using the webbrowser Module
File: webbrowser-example-1.py
import webbrowser
import time
webbrowser.open("http://www.pythonware.com")
# wait a while, and then go to another page
time.sleep(5)
webbrowser.open(
"http://www.pythonware.com/people/fredrik/librarybook.htm"
)
On Unix, this module supports lynx, Netscape, Mosaic, Konquerer, and
Grail. On Windows and Macintosh, it uses the standard browser (as
defined in the registry or the Internet configuration panel).
|