How to properly stop phantomjs execution

前端 未结 7 921
星月不相逢
星月不相逢 2020-11-29 21:30

I initiated and close phantomjs in Python with the following

from selenium import webdriver    
driver = webdriver.PhantomJS()
driver.get(url)
h         


        
7条回答
  •  长情又很酷
    2020-11-29 22:11

    driver.quit() did not work for me on Windows 10, so I ended up adding the following line right after calling driver.close():

    os.system('taskkill /f /im phantomjs.exe')
    

    where

    /f = force
    /im = by image name
    

    And since this is a Windows only solution, it may be wise to only execute if os.name == 'nt'

提交回复
热议问题