Home > Article > Backend Development > How to install Selenium+Headless Chrome in Python environment
This article mainly introduces how to install Selenium+Headless Chrome in the Python environment. The editor thinks it is quite good. Now I will share it with you and give it as a reference. . Let’s follow the editor to take a look.
I’ve been learning crawlers recently, and I suddenly discovered:
Python 3.6.4 (default, Jan 5 2018, 02:35:40) [GCC 7.2.1 20171224] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from selenium import webdriver >>> driver=webdriver.PhantomJS() /usr/lib/python3.6/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 '
Simply put, it means that the new version of Selenium no longer supports PhantomJS, please use A headless version of Chrome or Firefox instead. I'm confused...Many tutorials nowadays are based on PhantomJS. There is no way. Since I am using the Chrome browser, I will share the installation method of Headless Chrome.
from selenium import webdriverfrom 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('http://www.baidu.com')
The above is the detailed content of How to install Selenium+Headless Chrome in Python environment. For more information, please follow other related articles on the PHP Chinese website!