Python library for detecting and launching browsers
Project description
License | Version | ||
Github Actions | Coverage | ||
Supported versions | Wheel | ||
Status | Downloads |
browsers
Python library for detecting and launching browsers
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 seem to find an equivalent library in Python
Installation
pip install pybrowsers
Usage
Import
import browsers
List all installer browsers
import browsers
print(list(browsers.browsers()))
# [('chrome', {'path': '/Applications/Google Chrome.app', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}), ('firefox', {'path': '/Applications/Firefox.app', 'display_name': 'Firefox', 'version': '99.0.1'}), ('safari', {'path': '/Applications/Safari.app', 'display_name': 'Safari', 'version': '15.4'}), ('opera', {'path': '/Applications/Opera.app', 'display_name': 'Opera', 'version': '85.0.4341.60'}), ('msedge', {'path': '/Applications/Microsoft Edge.app', 'display_name': 'Microsoft Edge', 'version': '100.1185.22041544'})]
Get browser information
import browsers
print(browsers.get("chrome"))
# {'path': '/Applications/Google Chrome.app', 'display_name': 'Google Chrome', 'version': '100.0.4896.88'}
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"])
TODO:
- Detect browser on OSX
- Detect browser on Linux
- Detect browser on Windows
- Launch browser with arguments
- Get browser by version (support wildcards)
References
- httptoolkit/browser-launcher
- Desktop Entry Specification
- Github: webbrowser.open incomplete on Windows
- Stackoverflow: Grabbing full file version of an exe in Python
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pybrowsers-0.3.0.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for pybrowsers-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c676e510b0a795ac72b0cf72b7a544221a5ea0822bf20080164a3bf404290cad |
|
MD5 | 70d2eaf07c6c0d521d2ede22b42faf22 |
|
BLAKE2b-256 | 71461db56ca7ec5fc3840df31907eaedc1bc1cacc98d3e5aa3c6df2863efb449 |