This article mainly describes how to install selenium+headless Chrome in Python environment, small series feel very good, now share to everyone, but also for everyone to make a reference. Let's take a look at it with a little knitting.
Recently in learning reptiles, suddenly found:
Python 3.6.4 (Default, Jan 5 2018, 02:35:40) [GCC 7.2.1 20171224] on Linuxtype "help", "copyright", "credits" or "Lice NSE "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 have been deprecated, please use headless versions of Chrome or Firefox instead Warnings.warn (' Se Lenium support for PHANTOMJS have been deprecated, please use headless '
Simply put, it means that the new version of selenium no longer supports PHANTOMJS, please use Chrome or Firefox without a front-page replacement. To be ignorant of ... Now a lot of tutorials are based on PHANTOMJS Ah, no way, because I use a Chrome browser, share about headless chrome installation method.
1. Run cmd or CTRL + R to enter the command line
2. Enter Python
3. Enter a code block
code block syntax follows the standard markdown code, for example:
From selenium import webdriverfrom selenium.webdriver.chrome.options Import optionschrome_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 ')
OK, now you're ready to install headless chrome.