CentOS Installation Selenium+chrome

Source: Internet
Author: User

Reference https://cuiqingcai.com/4886.html

1234 # # Install the Yum source [root@spider01 ~]# sudo yum install-y epel-release # # Install chrome[root@spider01 ~]# yum Install-y chromium

Go to this place: Https://sites.google.com/a/chromium.org/chromedriver/downloads Download the Chromedriver driver in the/usr/bin/directory:

The completed results are as follows:

Shell
123 [root@spider01 ~]# ll/usr/bin/| grep chrom -rwxrwxrwx. 1 root root 7500280 November : Chromedriver lrwxrwxrwx. 1 RootRoot November : chromium-browser usr/lib64/chromium-browser/chromium-browser. sh

Install XVFB:

12 [root@spider01 ~]# yum install xvfb-y [root@spider01 ~]# yum Install xorg-x11-fonts*-y

New in/usr/bin/a file named Xvfb-chromium writes the following:

Shell
12345678910111213141516171819202122232425 [root@spider01 ~]# cat/usr/bin/xvfb-chromium #!/bin/bash_kill_procs() { kill -term $chromium wait $chromium kill -term $xvfb }# Setup A trap to catch SIGTERM and relay it to child processestrap _kill_procs SIGTERM XVFB_WHD=${XVFB_WHD:-1280x720x16} # Start XvfbXvfb :- ac -screen 0 $XVFB _whd - Nolisten TCP & Xvfb=$! export DISPLAY=: Chromium-- no-sandbox- -Disable-GPU$@ & Chromium=$! wait $chromium wait $xvfb

To change a soft connection:

Shell
1234567891011121314151617 # # Change chrome-enabled soft connect[root@spider01 ~]# ln-s/usr/lib64/chromium-browser/chromium-browser.sh/usr/bin/ Chromium [root@spider01 ~]# rm-rf/usr/bin/chromium-browser [root@spider01 ~]# ln-s/usr/bin/xvfb-chromium/usr/bin/chromium-browser [root@spider01 ~]# ln-s/usr/bin/xvfb-chromium/usr/bin/google-chrome [root@spider01 ~]# ll/usr/bin/| grep chrom* -rwxrwxrwx. 1 root root 7500280 November : Chromedriver lrwxrwxrwx. 1 RootRoot November : chromium /USR / lib64/chromium-browser/chromium-browser. SH lrwxrwxrwx. 1 root root        22 11 month 30 09:48 chromium-browser Span class= "Crayon-o" >-> /usr/bin/xvfb -chromium -rwxr-XR-x. 1 root root 73848 December 7 chronyc /c19> lrwxrwxrwx. 1 root root        22 11 month 30 09:48 google-chrome -> /usr /bin/xvfb-chromium -rwxrwxrwx. 1 root root 387 November : xvfb- chromium
Shell
123456 >>> from selenium import webdriver >>> driver = webdriver. Chrome() >>> driver. Get("http://www.baidu.com") >>> driverfind_element_by_xpath("./*//input[@id = ' kw ']"). Send_keys ("Ouch-trough") >>> driver. Find_element_by_xpath("./*//input[@id = ' su ']"). Click ()>>> driver. Page_source

CentOS Installation Selenium+chrome

Related Article

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.