20.1. webbrowser — Convenient Web-browser controller

The webbrowser module provides a high-level interface to allow displaying Web-based documents to users. Under most circumstances, simply calling the open() function from this module will do the right thing.

Please note: Editorial uses a custom version of this module that only supports the open() function. The behavior is different from other platforms in that web pages are opened in an embedded browser view within the app for http(s) and file URLs. For custom URL schemes that are registered by an app (e.g. mailto:), the registered app is opened. This also works for third-party apps.

webbrowser.open(url)

Display url in the in-app browser panel, if the scheme of the URL is http, https or file. Using other URL schemes can be used to open native apps that are registered for these schemes.

If you want to open http or https URLs in Safari instead of the built-in browser, you can replace http(s) with safari-http(s) in your URL, e.g. ‘safari-http://google.com’.

If the URL is valid (regardless of if it could actually be loaded by the browser) True is returned, otherwise False.

Please note: Pythonista supports some additional parameters for this function; these are currently ignored in Editorial.

webbrowser.can_open(url)

Return whether the given URL can be opened (either with the integrated browser, or by launching an external app).

Note: This function is iOS-specific.

webbrowser.add_to_reading_list(url[, title, preview_text])

Add a given URL with optional title and preview text to Safari’s Reading List.

Only http and https URLs are supported.