I want a way to find the default browser in Python. I've seen https://docs.python.org/3.8/library/webbrowser.html and there might be a way of converting a webbrowser instance which I do not know.
Does anybody know how I could go about doing that?
Also, I'm using Windows - it doesn't need to work for Mac or Ubuntu.
Edit:
I've already tried this website and it gives me an error saying that 'the file path does not exist'.
Additionally, I don't want to open a tab in the default browser, I just want the name.
Edit #2:
The following code works but returns Internet Explorer instead of my actual default which is Chrome.
from winreg import*
with OpenKey(HKEY_CLASSES_ROOT,r"http\\shell\\open\\command") as key:
cmd = QueryValue(key, None)
I have figured it out. I'm pretty sure this only works on Windows, but here's the code:
from winreg import *
with OpenKey(HKEY_CURRENT_USER, r"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice") as key:
browser = QueryValueEx(key, 'Progid')[0]
It will return ChromeHTML
for Chrome, FirefoxURL
for Firefox, and IE.HTTP
for Internet Explorer.