重新启动Firefox并恢复以前的会话

2024-10-01 09:25:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我对firefox有一个问题——过了一段时间,它的速度变慢了,但重启后又恢复了正常。我尝试刷新dns-不起作用。Celar缓存-不工作。所以我想制作一个python脚本,每30分钟重启一次Firefox并恢复上一个会话,但我不知道如何做

我尝试了任何可能的Firefox调整-没有任何效果

或者你知道如何解决这个问题


Tags: 脚本dnsfirefox速度效果celar
1条回答
网友
1楼 · 发布于 2024-10-01 09:25:29

我没有找到答案,所以我自己解决了

如果你对Firefox的性能有问题,这将非常有帮助

https://github.com/perdubaro/FirefoxRestarter

import subprocess
import time
import os

browserExe = "firefox.exe"


def ffrestart():
    while True:
        print("\nClosing Firefox\n")
        os.system("taskkill /f /im "+browserExe)
        print("\nWaiting 5 seconds...\n")
        time.sleep(5)
        p = subprocess.Popen(['C:\Program Files\Mozilla Firefox\\firefox.exe'], shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT, bufsize=0)
        print(p)
        print("\nWait 1 hour for next Restart\n")
        time.sleep(3600)


ffrestart()

相关问题 更多 >