使用Python開啟瀏覽器上網
import webbrowser
firefoxPath = r'C:\Program Files\Mozilla Firefox\firefox.exe'
webbrowser.register('firefox', None, webbrowser.BackgroundBrowser(firefoxPath))
with open("urls.txt") as f:
for url in f:
webbrowser.get('firefox').open(url,new=1,autoraise=True)
會寫這份程式的原因在於:電腦中的火狐瀏覽器並非預設瀏覽器,加上電腦與人共用,不想做更動。
參考資料: