How to close web browser using python

Pissu Pusa picture Pissu Pusa · Mar 3, 2017 · Viewed 29.7k times · Source

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?

Answer

Omid Estaji picture Omid Estaji · May 30, 2017

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")