Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead

Posted by Steven on 2018-04-18

前段时间在使用PhantomJS+Selenim做爬虫的时候,运行提示:

1
2
UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '

上面的提示的意思是:Selenim不再支持PhantomJS,请使用headless version 的Chrome或者Firefox替代

然后我在知乎上提问,大家都推荐 Headless Chrome[🔗【问题链接】](然后我在知乎上提问,大家都推荐 Headless Chrome)

怎么用

1
2
3
4
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=chrome_options) driver.get("https://cnblogs.com/")
参考文章

https://developers.google.com/web/updates/2017/04/headless-chrome

推荐文章