Last night I sent the following patch for urllib to python-patches: # Support for launching a browser if os.environ.has_key("BROWSER"): _browsers = string.split(os.environ["BROWSER"], ":") else: _browsers = ["mozilla %s &", "netscape -remote 'openURL(%s)'", "netscape %s &", "lynx %s &", "w3m %s &"] def urlbrowse(url): """Launch a browser, in background, pointed at the given URL. Accept either a string or a parsed URL tuple. Interpret the BROWSER environment variable, if it exists, as a colon-separated list of browser commands to try. """ from urlparse import urlunparse if type(url) == (): url = urlunparse(url) for browser in _browsers: if not os.system('which 1>/dev/null 2>&1 '+string.split(browser)[0]): if os.system((browser % url)) == 0: return 1 return 0 Obviously this is not portable off Unix. Equally obviously it should be possible to do an equivalent thing under Windows (at least). For anybody writing interactive programs in this Web-mad era, this function is just too useful not to have in the toolbox. So this is a nudge to any Windows and Mac wizards on this list -- let's make this function available cross-platform. I've also copied this note to Chip Salzenberg. Perl ought to have this capability too -- and I'm sufficiently serious about that to (gasp) code in Perl myself to make it happen if I have to. -- <a href="http://www.tuxedo.org/~esr">Eric S. Raymond</a> (Those) who are trying to read the Second Amendment out of the Constitution by claiming it's not an individual right (are) courting disaster by encouraging others to use the same means to eliminate portions of the Constitution they don't like. -- Alan Dershowitz, Harvard Law School
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4