“undetected-chromedriver在脚本执行完成后未正确退出”

huangapple go评论103阅读模式
英文:

undetected-chromedriver does not quit properly after script execution is complete

问题

我在代码的结尾使用了driver.quit(),它如预期地关闭了Chrome窗口,但在脚本执行完成后检查Windows任务管理器时,我发现Chrome任务仍在占用CPU资源 - 我确信这些任务来自undetected-chromedriver。

这里是一张截图 “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

here is a screenshot “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()

huangapple
  • 本文由 发表于 2023年6月12日 19:51:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76456385.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定