问题
I would like to write a script (in python) which scans the machine.(assumption is system has Linux) and retrieve the list of browser's installed. Looking for suggestions to implement it. I am using selenium to open linksbrowser = webdriver.Firefox()
Here we have to mention Firefox to open link in Firefox browser. What if user don't have Firefox in machine (chrome installed)?
I had already searched but haven't got any result.
P.S: If system has windows/Mac OS
回答1:
A better approach: use try/except block
try:
browser = webdriver.Firefox()
browser.get('url')
except (IOException, Exception):
pass
It will help in cases where driver is not able to find the browser or there is some problem while launching.
回答2:
You can scan all .desktop files in /usr/share/applications
looking for WebBrowser
in Categories
field.
来源:https://stackoverflow.com/questions/45885023/how-to-get-list-of-browser-installed-in-a-system-using-python