Installing the Python+selenium+chrome+chromedriver on the CENTOS7

Source: Internet
Author: User

1. Download Chrome

The previous article has demonstrated the Python+selenium+firefox+geckodriver installation steps and opened Baidu via automated scripting

So you only need to install chrome and chromedriver now.

Official website: https://www.google.cn/chrome/(can download the RPM package via Centos7 's own Firefox browser)

Baidu Cloud Download: Https://pan.baidu.com/s/1XLpKO-pIzxc0uw3h2u4YnQ (password: 0VU2)

Baidu cloud after download through xftp software to CENTOS7 server

2. Install Chrome

RPM-IVH google-chrome-stable_current_x86_64.rpm on the Centos7

if a dependency is missing, install the missing, then install Chrome, Example: yum-y install REDHAT-LSB

After the installation is complete we can see the app---the internet to see Google's icon on the GUI interface of CENTOS7

Note: The root user we found unable to open the newly installed Google Browser, we need to modify the configuration again

Vim/opt/google/chrome/google-chrome

Change the last line to

Exec-a "$" "$HERE/chrome" "[email protected]"--no-sandbox

Save and exit, and finally successfully open Google Chrome

3.Chrome and Chromedriver correspondence table

Google browser driver and Google one by one corresponding, if the installed version does not match, the late code in the call will be error, this is important, be sure to note

4. Installing Chromedriver

Download and chromedriver version of Chrome

: https://chromedriver.storage.googleapis.com/index.html

Transfer to CENTOS7 server via xftp software after download is complete

(1) Decompression software unzip Chromedriver_linux64.zip

(2) Move the software to the appropriate directory

MV chromedriver/usr/local/bin/(very important)
(3) Assigning permissions

chmod +x/usr/local/bin/chromedriver
(4) Verify the installation is complete

Direct Input Chromedriver
  

5. Code Validation

To create a. py file

Touch ceshi.py

Vim ceshi.py

Enter the following content

#Implement automatic login Baidu fromSeleniumImportWebdriver fromTimeImportSleep#New Webdriver ObjectDriver =Webdriver. Chrome () Driver.maximize_window () Driver.get ('Https://passport.baidu.com/v2/?login') Sleep (2) driver.find_element_by_id ("tangram__psp_3__footeruloginbtn"). Click () driver.find_element_by_name ("UserName"). Clear () Driver.find_element_by_name ("UserName"). Send_keys ('xiaoxing') Driver.find_element_by_name ("Password"). Clear () Driver.find_element_by_name ("Password"). Send_keys ('******') driver.find_element_by_id ("Tangram__psp_3__submit"). Click ()

Run script python ceshi.py successfully login Baidu

Installing the Python+selenium+chrome+chromedriver on the CENTOS7

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.