How to close web browser using python
Asked Answered
M

2

12

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?

Mellisamellisent answered 3/3, 2017 at 1:14 Comment(2)
have you seen this: #29187344Luanneluanni
please read this: reddit.com/r/learnpython/comments/317yct/…Interventionist
A
12

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")
Appointee answered 30/5, 2017 at 8:48 Comment(1)
What's the extension we'd use for a chrome incognito window?Hawaii
B
6

For MacOS, you can use below command:

os.system("killall -9 'Google Chrome'")
Bambibambie answered 28/6, 2018 at 4:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.