PhantomJS报错warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '

原因:Selenuim已经放弃PhantomJS3.x了,建议使用火狐或者谷歌无头浏览器。

解决方法:

  1.phantomjs降级,换个2.x版本的

  2.使用无头浏览器,示例代码(自己改了改,如有错误还望指正)

  

 1 from selenium import webdriver
 2 from selenium.webdriver.chrome.options import Options
 3 
 4 
 5 chrome_options = Options()
 6 chrome_options.add_argument('--headless')
 7 driver = webdriver.Chrome(chrome_options=chrome_options)
 8 driver.get("https://www.baidu.com")
 9 print(driver.current_url)
10 driver.close()

 运行结果

为了紧跟时代,还是使用无头浏览器吧

猜你喜欢

转载自www.cnblogs.com/MC-Curry/p/9146062.html