How to install selenium+headless Chrome in a python environment

Source: Internet
Author: User
Tags deprecated


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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.