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?

Pissu Pusa
  • 1,218
  • 3
  • 16
  • 26
  • 2
    have you seen this: http://stackoverflow.com/questions/29186844/how-to-close-an-internet-tab-with-cmd-python – Shubham Namdeo Mar 03 '17 at 01:16
  • please read this: https://www.reddit.com/r/learnpython/comments/317yct/i_have_code_that_opens_a_webbrowser_now_how_do_i/ – dima Mar 03 '17 at 01:34

2 Answers2

11

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")
Community
  • 1
  • 1
Omid Estaji
  • 303
  • 5
  • 10
5

For MacOS, you can use below command:

os.system("killall -9 'Google Chrome'")
Nishad Hameed
  • 76
  • 1
  • 1