如何正确停止phantomjs执行 [英] How to properly stop phantomjs execution

查看:428
本文介绍了如何正确停止phantomjs执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在Python中启动并关闭了phantomjs

I initiated and close phantomjs in Python with the following

from selenium import webdriver    
driver = webdriver.PhantomJS()
driver.get(url)
html_doc = driver.page_source
driver.close()

但脚本结束执行后,我仍在Mac活动监视器中找到phantomjs的实例.实际上,每次我运行脚本时,都会创建一个新进程phantomjs.

yet after the script ends execution I still find an instance of phantomjs in my Mac Activity Monitor. And actually every time I run the script a new process phantomjs is created.

我应该如何关闭驱动程序?

How should I close the driver?

推荐答案

不能保证.close()方法释放与驱动程序实例关联的所有资源.请注意,这些资源包括但不限于驱动程序可执行文件(在这种情况下为PhantomJS). .quit()方法旨在释放驱动程序的所有资源,包括退出可执行进程.

The .close() method is not guaranteed to release all resources associated with a driver instance. Note that these resources include, but may not be limited to, the driver executable (PhantomJS, in this case). The .quit() method is designed to free all resources of a driver, including exiting the executable process.

这篇关于如何正确停止phantomjs执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆