Pissu Pusa
Pissu Pusa

Reputation: 1374

How to close web browser using python

I have opened a webbrowser window using webbrowser.open(url) in python now I want to close the webbrowser opened using python. Is it possible to do so?

Upvotes: 12

Views: 60644

Answers (2)

Omid Estaji
Omid Estaji

Reputation: 320

There is no webbrowser.close, you can use these codes to close the task(in Windows OS):

First Import os package with

import os

then use system function to kill the task

os.system("taskkill /im firefox.exe /f")
os.system("taskkill /im chrome.exe /f")

Upvotes: 12

Nishad Hameed
Nishad Hameed

Reputation: 86

For MacOS, you can use below command:

os.system("killall -9 'Google Chrome'")

Upvotes: 6

Related Questions