<table>
<tr>
<td>License</td>
<td><img src='https://img.shields.io/pypi/l/pybrowsers.svg?style=for-the-badge' alt="License"></td>
<td>Version</td>
<td><img src='https://img.shields.io/pypi/v/pybrowsers.svg?logo=pypi&style=for-the-badge' alt="Version"></td>
</tr>
<tr>
<td>Github Actions</td>
<td><img src='https://img.shields.io/github/actions/workflow/status/roniemartinez/browsers/python.yml?branch=master&label=actions&logo=github%20actions&style=for-the-badge' alt="Github Actions"></td>
<td>Coverage</td>
<td><img src='https://img.shields.io/codecov/c/github/roniemartinez/browsers/master?label=codecov&logo=codecov&style=for-the-badge' alt="CodeCov"></td>
</tr>
<tr>
<td>Supported versions</td>
<td><img src='https://img.shields.io/pypi/pyversions/pybrowsers.svg?logo=python&style=for-the-badge' alt="Python Versions"></td>
<td>Wheel</td>
<td><img src='https://img.shields.io/pypi/wheel/pybrowsers.svg?style=for-the-badge' alt="Wheel"></td>
</tr>
<tr>
<td>Status</td>
<td><img src='https://img.shields.io/pypi/status/pybrowsers.svg?style=for-the-badge' alt="Status"></td>
<td>Downloads</td>
<td><img src='https://img.shields.io/pypi/dm/pybrowsers.svg?style=for-the-badge' alt="Downloads"></td>
</tr>
<tr>
<td>All Contributors</td>
<td><a href="#contributors-"><img src='https://img.shields.io/github/all-contributors/roniemartinez/browsers?style=for-the-badge' alt="All Contributors"></a></td>
</tr>
</table>
# 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
```bash
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
```python
import browsers
```
### List all installed browsers
```python
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
```python
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
```python
import browsers
browsers.launch("chrome")
```
### Launch browser with URL
```python
import browsers
browsers.launch("chrome", url="https://github.com/roniemartinez/browsers")
```
### Launch browser with arguments
```python
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.
```python
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](https://github.com/httptoolkit/browser-launcher)
- [Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/latest/)
- [Github: webbrowser.open incomplete on Windows](https://github.com/python/cpython/issues/52479#issuecomment-1093496412)
- [Stackoverflow: Grabbing full file version of an exe in Python](https://stackoverflow.com/a/68774871/1279157)
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://ron.sh/"><img src="https://avatars.githubusercontent.com/u/2573537?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ronie Martinez</b></sub></a><br /><a href="https://github.com/roniemartinez/browsers/commits?author=roniemartinez" title="Code">💻</a> <a href="#ideas-roniemartinez" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/roniemartinez/browsers/commits?author=roniemartinez" title="Documentation">📖</a> <a href="#maintenance-roniemartinez" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://t.me/automation_remarks_ua"><img src="https://avatars.githubusercontent.com/u/4622856?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sergey Pirogov</b></sub></a><br /><a href="https://github.com/roniemartinez/browsers/issues?q=author%3ASergeyPirogov" title="Bug reports">🐛</a></td>
</tr>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Raw data
{
"_id": null,
"home_page": "https://github.com/roniemartinez/browsers",
"name": "pybrowsers",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0.0,>=3.8.1",
"maintainer_email": null,
"keywords": null,
"author": "Ronie Martinez",
"author_email": "ronmarti18@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/12/73/11f9a84df5fdc5d88b33b992af9a6caf96e09ad84cf3c0026f76af0e1bac/pybrowsers-0.6.0.tar.gz",
"platform": null,
"description": "<table>\n <tr>\n <td>License</td>\n <td><img src='https://img.shields.io/pypi/l/pybrowsers.svg?style=for-the-badge' alt=\"License\"></td>\n <td>Version</td>\n <td><img src='https://img.shields.io/pypi/v/pybrowsers.svg?logo=pypi&style=for-the-badge' alt=\"Version\"></td>\n </tr>\n <tr>\n <td>Github Actions</td>\n <td><img src='https://img.shields.io/github/actions/workflow/status/roniemartinez/browsers/python.yml?branch=master&label=actions&logo=github%20actions&style=for-the-badge' alt=\"Github Actions\"></td>\n <td>Coverage</td>\n <td><img src='https://img.shields.io/codecov/c/github/roniemartinez/browsers/master?label=codecov&logo=codecov&style=for-the-badge' alt=\"CodeCov\"></td>\n </tr>\n <tr>\n <td>Supported versions</td>\n <td><img src='https://img.shields.io/pypi/pyversions/pybrowsers.svg?logo=python&style=for-the-badge' alt=\"Python Versions\"></td>\n <td>Wheel</td>\n <td><img src='https://img.shields.io/pypi/wheel/pybrowsers.svg?style=for-the-badge' alt=\"Wheel\"></td>\n </tr>\n <tr>\n <td>Status</td>\n <td><img src='https://img.shields.io/pypi/status/pybrowsers.svg?style=for-the-badge' alt=\"Status\"></td>\n <td>Downloads</td>\n <td><img src='https://img.shields.io/pypi/dm/pybrowsers.svg?style=for-the-badge' alt=\"Downloads\"></td>\n </tr>\n <tr>\n <td>All Contributors</td>\n <td><a href=\"#contributors-\"><img src='https://img.shields.io/github/all-contributors/roniemartinez/browsers?style=for-the-badge' alt=\"All Contributors\"></a></td>\n </tr>\n</table>\n\n# browsers\n\nPython library for detecting and launching browsers\n\n\n## Why?\n\nI recently wrote a snippet for detecting installed browsers in an OSX machine in \nhttps://github.com/mitmproxy/mitmproxy/issues/5247#issuecomment-1095337723 based on https://github.com/httptoolkit/browser-launcher\nand I thought this could be useful to other devs since I cannot find an equivalent library of `httptoolkit/browser-launcher` in Python\nand the known `webbrowser` standard library does not support arguments.\n\n## Installation\n\n```bash\npip install pybrowsers\n```\n\n## Features\n\n- Detect browser on OSX\n- Detect browser on Linux\n- Detect browser on Windows\n- Launch browser with arguments\n- Launch and get browser by version with wildcard support\n\n## Usage\n\n### Import\n\n```python\nimport browsers\n```\n\n### List all installed browsers\n\n```python\nimport browsers\n\nprint(list(browsers.browsers()))\n# [{'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'}]\n```\n\n### Get browser information\n\n```python\nimport browsers\n\nprint(browsers.get(\"chrome\"))\n# {'browser_type': 'chrome', 'path': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}\n```\n\n### Launch browser\n\n```python\nimport browsers\n\nbrowsers.launch(\"chrome\")\n```\n\n### Launch browser with URL\n\n```python\nimport browsers\n\nbrowsers.launch(\"chrome\", url=\"https://github.com/roniemartinez/browsers\")\n```\n\n### Launch browser with arguments\n\n```python\nimport browsers\n\nbrowsers.launch(\"chrome\", args=[\"--incognito\"])\n```\n\n### Specifying version\n\nThe `get()` and `launch()` functions support specifying version in case multiple versions are installed.\nWildcard pattern is also supported.\n\n```python\nimport browsers\n\nprint(browsers.get(\"chrome\", version=\"100.0.4896.127\")) # complete version\n# {'browser_type': 'chrome', 'path': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}\n\nprint(browsers.get(\"chrome\", version=\"100.*\")) # wildcard\n# {'browser_type': 'chrome', 'path': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'display_name': 'Google Chrome', 'version': '100.0.4896.127'}\n\nbrowsers.launch(\"chrome\", version=\"100.0.4896.127\") # complete version\nbrowsers.launch(\"chrome\", version=\"100.*\") # wildcard\n```\n\n## References\n\n- [httptoolkit/browser-launcher](https://github.com/httptoolkit/browser-launcher)\n- [Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/latest/)\n- [Github: webbrowser.open incomplete on Windows](https://github.com/python/cpython/issues/52479#issuecomment-1093496412)\n- [Stackoverflow: Grabbing full file version of an exe in Python](https://stackoverflow.com/a/68774871/1279157)\n\n## Contributors \u2728\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tr>\n <td align=\"center\"><a href=\"https://ron.sh/\"><img src=\"https://avatars.githubusercontent.com/u/2573537?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Ronie Martinez</b></sub></a><br /><a href=\"https://github.com/roniemartinez/browsers/commits?author=roniemartinez\" title=\"Code\">\ud83d\udcbb</a> <a href=\"#ideas-roniemartinez\" title=\"Ideas, Planning, & Feedback\">\ud83e\udd14</a> <a href=\"https://github.com/roniemartinez/browsers/commits?author=roniemartinez\" title=\"Documentation\">\ud83d\udcd6</a> <a href=\"#maintenance-roniemartinez\" title=\"Maintenance\">\ud83d\udea7</a></td>\n <td align=\"center\"><a href=\"https://t.me/automation_remarks_ua\"><img src=\"https://avatars.githubusercontent.com/u/4622856?v=4?s=100\" width=\"100px;\" alt=\"\"/><br /><sub><b>Sergey Pirogov</b></sub></a><br /><a href=\"https://github.com/roniemartinez/browsers/issues?q=author%3ASergeyPirogov\" title=\"Bug reports\">\ud83d\udc1b</a></td>\n </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python library for detecting and launching browsers",
"version": "0.6.0",
"project_urls": {
"Donate": "https://github.com/sponsors/roniemartinez",
"Homepage": "https://github.com/roniemartinez/browsers",
"Repository": "https://github.com/roniemartinez/browsers"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2c175979276ec9973c0c87ce501013d41878a422d662d174ad41dc79668359af",
"md5": "dd47c096e41bd094bcf1c56af7d45481",
"sha256": "2c672148462bf0daca0ff5fece24c1bfde7370277fecdadf313d5249f9b91ca6"
},
"downloads": -1,
"filename": "pybrowsers-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dd47c096e41bd094bcf1c56af7d45481",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.8.1",
"size": 8406,
"upload_time": "2024-05-26T13:46:30",
"upload_time_iso_8601": "2024-05-26T13:46:30.995221Z",
"url": "https://files.pythonhosted.org/packages/2c/17/5979276ec9973c0c87ce501013d41878a422d662d174ad41dc79668359af/pybrowsers-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "127311f9a84df5fdc5d88b33b992af9a6caf96e09ad84cf3c0026f76af0e1bac",
"md5": "5cc28e4a0f33d2d5679111a65c7fe202",
"sha256": "b683fd6fd308d07a285428da7cb025c6684922ef78c42b12dc4dd06b538b5473"
},
"downloads": -1,
"filename": "pybrowsers-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "5cc28e4a0f33d2d5679111a65c7fe202",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.8.1",
"size": 7300,
"upload_time": "2024-05-26T13:46:32",
"upload_time_iso_8601": "2024-05-26T13:46:32.680280Z",
"url": "https://files.pythonhosted.org/packages/12/73/11f9a84df5fdc5d88b33b992af9a6caf96e09ad84cf3c0026f76af0e1bac/pybrowsers-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-26 13:46:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "roniemartinez",
"github_project": "browsers",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pybrowsers"
}