E:\py\python3.7\Python37\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py:49: 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 '
translate : User warning :Selenium Yes PhantomJS The support of has been abandoned , Please use the headless version of Chrome or Firefox Instead of
Warning .“Selenium Yes PhantomJS The support of has been abandoned , Please use headless”
PS E:\py\python3.7\test2\test43> python3 -m pip show selenium
WARNING: Ignoring invalid distribution -ip (e:\py\python3.7\python37\lib\site-packages)
Name: selenium nlmZwRtFAwvDqyjOWdztaPdjM-givOWr5tL8Y8cO71pvZnaQa09ueKNNzeKhzVvuSUm_l2xhhA_FfOm8cfTeE26tGtIozKPVfiWbkc4PxKBRLa9qx8CKGFjLeGZQtdjGuBoE2lUr-Version: 3.141.0
Summary: Python bindings for Selenium
Home-page: https://github.com/SeleniumHQ/selenium/ hantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
Author: UNKNOWN
Author-email: UNKNOWN
License: Apache 2.0
Location: e:\py\python3.7\python37\lib\site-packages
Requires: urllib3
Required-by:
1、selenium Version downgrade
2、 adopt python3 -m pip uninstall selenium uninstall , Reinstall the specified version python3 -m pip install selenium==2.48.0
3、 Run again
Solution
Prerequisite :
Sample code :
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
def main():
options = Options()
options.add_argument('-headless')
driver = Firefox(executable_path='./geckodriver', firefox_options=options)
driver.get("https://www.qiushibaike.com/8hr/page/1/")
print(driver.page_source)
driver.close()
if __name__ == '__main__':
main()
Selenium+Headless Chrome
And Firefox similar
Prerequisite :
Example :
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def main():
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(executable_path='./chromedriver', chrome_options=chrome_options)
driver.get("https://www.baidu.com")
print(driver.page_source)
driver.close()
if __name__ == '__main__':
main()
Share :
Most people who achieve great things are tolerant 、 Bear the mind that people cannot bear , Be good at seeking common ground while reserving minor differences , Unite the majority . They don't haggle over every ounce , Do not dwell on non principled trivia , That's why big things happen , Establish great cause .