#browser #webbrowser

webbrowser

Open URLs in web browsers available on a platform

16 unstable releases (6 breaking)

0.7.1 Apr 27, 2022
0.6.0 Feb 19, 2022
0.5.5 Jul 19, 2020
0.5.2 Aug 22, 2019
0.1.2 Dec 8, 2015

#8 in WebAssembly

Download history 13371/week @ 2022-01-27 13913/week @ 2022-02-03 15853/week @ 2022-02-10 16199/week @ 2022-02-17 16069/week @ 2022-02-24 14817/week @ 2022-03-03 15570/week @ 2022-03-10 17228/week @ 2022-03-17 16806/week @ 2022-03-24 18847/week @ 2022-03-31 17476/week @ 2022-04-07 16872/week @ 2022-04-14 17343/week @ 2022-04-21 20574/week @ 2022-04-28 19050/week @ 2022-05-05 16590/week @ 2022-05-12

77,019 downloads per month
Used in 180 crates (108 directly)

MIT/Apache

34KB
605 lines

webbrowser

Current Crates.io Version Crates.io Downloads License

Linux Build Windows Build MacOS Build Android Build WASM Build

Rust library to open URLs in the web browsers available on a platform

Inspired by the webbrowser python library

Documentation

Examples

use webbrowser;

if webbrowser::open("http://github.com").is_ok() {
    // ...
}

Platform Support

Platform Supported Browsers Test status
macos default + others
windows default only
linux/*bsd default only (respects $BROWSER env var, so can be used with other browsers)
android default only
wasm default only
haiku ✅ (experimental) default only
ios default only

Consistent Behaviour

webbrowser defines consistent behaviour on all platforms as follows:

  • Non-Blocking for GUI based browsers (e.g. Firefox, Chrome etc.), while Blocking for text based browser (e.g. lynx etc.)
  • Suppressed output by default for GUI based browsers, so that their stdout/stderr don't pollute the main program's output. This can be overridden by webbrowser::open_browser_with_options.

Looking to contribute?

PRs invited for

  • Support for other platforms, e.g. iOS

Important note (while testing):

  • This library requires availability of browsers and a graphical environment during runtime
  • cargo test will actually open the browser locally

When contributing, please note that your work will be dual licensed as MIT + Apache-2.0 (see below).

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.3–4.5MB
~109K SLoC