英文:
undetected-chromedriver does not quit properly after script execution is complete
问题
我在代码的结尾使用了driver.quit()
,它如预期地关闭了Chrome窗口,但在脚本执行完成后检查Windows任务管理器时,我发现Chrome任务仍在占用CPU资源 - 我确信这些任务来自undetected-chromedriver。
是否有人遇到过这个问题,我该如何确保undetected-chromedriver能正确终止并不会留下任何正在运行的后台任务?
英文:
I use driver.quit()
at the end of my code, and it closes the Chrome window as expected, but when checking Task Manager on Windows after script execution is complete, I find Chrome tasks that are eating up the CPU - and I'm certain that those tasks are from undetected-chromedriver
did anyone face this issue, and how do I make sure that undetected-chromedriver terminates properly and does not leave any running background tasks?
答案1
得分: 1
只删除该选项并使用driver = uc.Chrome()
,应该能正常终止。
英文:
I had this issue before as I was using subprocess driver = uc.Chrome(use_subprocess=True)
. just remove that option and use driver = uc.Chrome()
and it should terminate properly.
答案2
得分: 1
您可以使用SeleniumBase的undetected-chromedriver模式以获得最佳使用效果:
pip install seleniumbase
,然后使用以下Python脚本运行:
from seleniumbase import Driver
import time
driver = Driver(uc_cdp=True, incognito=True)
driver.get("https://nowsecure.nl/#relax")
time.sleep(8)
driver.quit()
英文:
You can use SeleniumBase's undetected-chromedriver mode for optimal use:
pip install seleniumbase
, and then run the following script with python
:
from seleniumbase import Driver
import time
driver = Driver(uc_cdp=True, incognito=True)
driver.get("https://nowsecure.nl/#relax")
time.sleep(8)
driver.quit()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论