First, install and pip Python3
Download the installation package python3
Execute the command: wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
Install zlib-devel package (mounted behind pip need to use, where to download, behind would not repeat the compilation)
yum install zlib-devel
Unzip command:
tar -xvf Python-3.6.5.tgz
Unzip the file will move to the next usr / local directory
mv Python-3.6.5 cd /usr/local
Create a directory in the local directory python3
mkdir /usr/local/python3
Go to the unpack folder
cd /usr/local/Python-3.6.5
Configuring installation directory
./configure --prefix=/usr/local/python3
Compile source code
make
Implementation of the source code installation
make install or (make && make install and above two steps is a mean)
Configuration software connection
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
Go to the root directory
cd /
Enter python3 see the message indicates that the installation was successful
Installation pip
Installation depends Environment
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
Install setuptools
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6
python3 setup.py build
python3 setup.py install
Installation PIP
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.2.tar.gz
cd pip-8.0.2
python setup.py build
sudo python setup.py install
Set soft links
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
The soft link is set incorrectly, remove soft links command
rm -rf / usr / bin / pip3 (back / usr / bin / pip soft link name, remember not to add at the end / as: / usr / bin / pip3 / delete soft connection and said the real file)
Back to the root directory
cd /
Enter pip3 -V View pip version, the installation is successful then the correct version display
Install chrome
yum install online
yum install google-chrome-stable_current_x86_64.rpm
Or specified address
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
After the installation is complete, check the version number under
> google-chrome -version
Google Chrome 77.0.3865.90
chromedriver drive
Download chromedriver driver, version history http://npm.taobao.org/mirrors/chromedriver find the corresponding driver version
You can use wget to download the zip package
wget http://npm.taobao.org/mirrors/chromedriver/77.0.3865.40/chromedriver_linux64.zip
Extract the zip package, if prompted no zip, it is yum -y install zip
first mounted
Extract the zip unzip chromedriver_linux64.zip #
Unzip chromedriver move to the next / usr / bin / directory
mv chromedriver /usr/bin/
View chromedriver version number
> chromedriver --version
ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442})
Installation selenium
Install the latest version of selenium 3.141.0
pip3 install selenium
Run selenium Code
Create a .py file, run the test code
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--headless') # 无界面 chrome_options.add_argument('--no-sandbox') # 解决DevToolsActivePort文件不存在报错问题 chrome_options.add_argument('--disable-gpu') # 禁用GPU硬件加速。如果软件渲染器没有就位,则GPU进程将不会启动。 chrome_options.add_argument('--disable-dev-shm-usage') chrome_options.add_argument('--window-size=1920,1080') # 设置当前窗口的宽度和高度 driver = webdriver.Chrome('chromedriver',chrome_options=chrome_options) driver.get("https://www.baidu.com/") print(driver.page_source) driver.quit()
Run the code