python webbrowser模块只打开不同浏览器中的特定链接

2024-05-14 19:21:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Safari作为默认浏览器。它只在Firefox中打开forvo.com,在Safari中打开其余的链接。我得到以下错误: 0:45: execution error: AppleEvent timed out. (-1712)

我尝试了异常处理。 一旦我删除了forvo.com,一切都按预期进行

import webbrowser


voc = "test"
links = (
    "http://www.collinsdictionary.com/dictionary/english/" + voc,
    "https://www.google.co.uk/search?q=" + voc +
        "&biw=1250&bih=782&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi_3vGFt67NAhWFApoKHREWC94Q_AUIBygC",
    "http://forvo.com/search/" + voc + "/"
        )

for i in links:
    webbrowser.open(i)

Tags: comhttpsearch链接www错误浏览器error

热门问题