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.2.0.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for pybrowsers-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4520e6575326057f54034691ba0a42c6a2bf87eb163c09241da81f73aeb5dc7d |
|
MD5 | 551f3fe7272c7dbd314724ef9aaf4985 |
|
BLAKE2b-256 | ebfba92d53c18d6af9abe9d81cc13ca388a91be329ddb79c43c8323f54a7b95e |