| License | Version | ||
| Github Actions | Coverage | ||
| Supported versions | Wheel | ||
| Status | Downloads | ||
| All Contributors |
browsers
Python library for detecting and launching browsers
Why?
I recently wrote a snippet for detecting installed browsers in an OSX machine in
https://github.com/mitmproxy/mitmproxy/issues/5247#issuecomment-1095337723 based on https://github.com/httptoolkit/browser-launcher
and I thought this could be useful to other devs since I cannot find an equivalent library of httptoolkit/browser-launcher in Python
and the known webbrowser standard library does not support arguments.
Installation
pip install pybrowsers
Features
- Detect browser on OSX
- Detect browser on Linux
- Detect browser on Windows
- Launch browser with arguments
- Launch and get browser by version with wildcard support
Usage
Import
import browsers
List all installed browsers
import browsers
print(list(browsers.browsers()))
# [{'browser_type': 'chrome', 'path': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}, {'browser_type': 'firefox', 'path': '/Applications/Firefox.app/Contents/MacOS/firefox', 'display_name': 'Firefox', 'version': '99.0.1'}, {'browser_type': 'safari', 'path': '/Applications/Safari.app/Contents/MacOS/Safari', 'display_name': 'Safari', 'version': '15.4'}, {'browser_type': 'opera', 'path': '/Applications/Opera.app/Contents/MacOS/Opera', 'display_name': 'Opera', 'version': '85.0.4341.60'}, {'browser_type': 'msedge', 'path': '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', 'display_name': 'Microsoft Edge', 'version': '100.1185.22042050'}]
Get browser information
import browsers
print(browsers.get("chrome"))
# {'browser_type': 'chrome', 'path': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}
Launch browser
import browsers
browsers.launch("chrome")
Launch browser with URL
import browsers
browsers.launch("chrome", url="https://github.com/roniemartinez/browsers")
Launch browser with arguments
import browsers
browsers.launch("chrome", args=["--incognito"])
Specifying version
The get() and launch() functions support specifying version in case multiple versions are installed.
Wildcard pattern is also supported.
import browsers
print(browsers.get("chrome", version="100.0.4896.127")) # complete version
# {'browser_type': 'chrome', 'path': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}
print(browsers.get("chrome", version="100.*")) # wildcard
# {'browser_type': 'chrome', 'path': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}
browsers.launch("chrome", version="100.0.4896.127") # complete version
browsers.launch("chrome", version="100.*") # wildcard
References
- httptoolkit/browser-launcher
- Desktop Entry Specification
- Github: webbrowser.open incomplete on Windows
- StackOverflow: Finding the version of an application from Python?
Contributors ✨
Thanks goes to these wonderful people (emoji key):
Ronie Martinez 💻 🤔 📖 🚧 |
Sergey Pirogov 🐛 |
vanderboon 💻 |
Stanislav Pankevich 🐛 |
Amir Rossert 💻 |
Deep-Tech Showcase and Eaglepoint Funding 🐛 |
dmnmsc 🐛 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Metadata
Release files for pybrowsers 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pybrowsers-1.4.0.tar.gz | 8.4 kB | Without provenance | Details for pybrowsers-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pybrowsers-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for pybrowsers-1.4.0-py3-none-any.whl |
Total release size: 18.6 kB
Release files / pybrowsers-1.4.0.tar.gz
| Download URL | pybrowsers-1.4.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a23d000f5a1669e309ab584cce67ca6021280d6bf5f6e489331349db3ef9961
|
|
BLAKE2b-256 checksum How to use checksums |
1ed9f574f6f9f982c1d8b06091da9b38497dba033f00559b0fdeae7def4ef667
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pybrowsers-1.4.0-py3-none-any.whl
| Download URL | pybrowsers-1.4.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06f0448a86f11119cf4f15978e846ca04afab54a4573f4f49c0262cecede26ae
|
|
BLAKE2b-256 checksum How to use checksums |
459720a0b77378c1c9f0bb4738f1d9864c4f726b12a4194afdde4b7990b9a344
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pybrowsers 1.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.