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.1.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for pybrowsers-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20456a2955a0fafd4bb885763720a0ddc314c50bc9fc9ead7975c47109fcebe5 |
|
MD5 | c42d4092718f88ed39230acc54ce34f3 |
|
BLAKE2b-256 | 5e803be6a41b72f349bbf7d10930b32930774ebf253fc1ce03fb5f1a2285b8a1 |