1

I would like to run a python automation that will kill a particular chrome tab, by its url name.

For example:
if time is 09:00, and url is "www.youtube.com", kill this process.

I didn't manage to do it using psutil, with the following code, since I could only fetch process name (chrome.exe), and not each particular url name.

    for proc in psutil.process_iter():
        try:
            # Get process name & pid from process object.
            processName = proc.name()
            processID = proc.pid
            print(processName, ' ::: ', processID)
        except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
            pass

But the output would be as the following:
enter image description here

also, I tried some other python packages, such as webbrowser and os, but didn;t find one of them helpful.

I would like to add that while opening the task manager, it is possible to see all of the open tabs and their urls.

enter image description here

So, I would like to ask - do you know what's the easiet way to close a chrome tab by its url?

Thanks!

1 Answers1

0

I just found this Python using Chrome Task manager recently while trying to implement a similar feature

I'm sure you'll get some ideas here.

Ashwin Raikar
  • 108
  • 1
  • 2
  • 8