how to get list of browser installed in a system using python?

流过昼夜 提交于 2021-02-19 07:05:34

问题


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 links
browser = 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!