Python opens the browser, can do a simple Brush Web page applet and other imaginative programs. But for study only, do not use illegal use.
Python's WebBrowser module supports a number of actions on the browser
There are three main ways to do this:
Webbrowser.open (URL, new=0, autoraise=true) webbrowser.open_new (URL) webbrowser.open_new_tab (URL)
The above three methods can be any one, under the python2.7 test pass, but this to test under Windows OH
We need to understand the Webbrowser.open () method:
Webbrowser.open (URL, new=0, autoraise=true)
Access the URL address in the system's default browser, if New=0,url will be in the same
Open in the browser window; if new=1, the new browser window will be opened; new=2
The new browser tab will be opened.
The Webbrowser.get () method can get the action object to the System browser.
The Webbrowser.register () method can register the browser type, while the type name that is allowed to be registered is as follows:
Type name Class name Notes ' Mozilla ' Mozilla (' Mozilla ') ' Firefox ' Mozilla (' Mozilla ' ) ' Netscape ' Mozilla (' Netscape ' Galeon ' Galeon (' Galeon ') ' Epiphany ' Galeon (' epiphany ') ' Skipstone ' Backgroundbrowser (' Skipstone ') ' kfmclient ' Konqueror () (1) ' Konqueror ' Konqueror () (1) ' KFM ' Konqueror () (1) ' Mosaic ' backgroundbrowser (' mosaic ') ' Opera ' opera ' () ' Grail ' grail () ' links ' genericbrowser (' links ') ' elinks ' elinks (' elinks ') ' Lynx ' Genericbrowser (' Lynx ') ' w3m ' genericbrowser (' w3m ') ' Windows-default ' Windowsdefault (2) ' MacOSX ' MacOSX (' Default ') (3) ' Safari ' MacOSX (' Safari ') (3) ' Google-chrome ' Chrome (' google-chrome ') ' Chrome ' chrome (' chrome ') ' chromium ' chromium (' chromium ') ' chromium-browser ' chromium (' chromium-browser ')
Instance:
#!/usr/bin/env python#-*-coding:utf-8-*-import webbrowserurl = ' http://www.pythontab.com ' webbrowser.open (URL) print Webbrowser.get ()
It's very simple, and it's going to be a deeper use. Ha, Donuts