正文
PhantomJS报错warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
原因:Selenuim已经放弃PhantomJS3.x了,建议使用火狐或者谷歌无头浏览器。
解决方法:
1.phantomjs降级,换个2.x版本的
2.使用无头浏览器,示例代码(自己改了改,如有错误还望指正)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options chrome_options = Options()
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.baidu.com")
print(driver.current_url)
driver.close()
运行结果
为了紧跟时代,还是使用无头浏览器吧