虚拟机Ubuntu安装google chrome、chromedriver、Selenium

安装google chrome

一、下载软件包

本安装选择下载.deb包。

可以直接进https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb下载。

也可以在Ubuntu终端中,使用wget下载。

二、安装软件包

$ sudo dpkg -i google-chrome-stable_current_amd64.deb


正在选中未选择的软件包 google-chrome-stable。
(正在读取数据库 ... 系统当前共安装有 226864 个文件和目录。)
正准备解包 google-chrome-stable_current_amd64.deb  ...
正在解包 google-chrome-stable (63.0.3239.84-1) ...
正在设置 google-chrome-stable (63.0.3239.84-1) ...
update-alternatives: 使用 /usr/bin/google-chrome-stable 来在自动模式中提供 /usr/bin/x-www-browser (x-www-browser)
update-alternatives: 使用 /usr/bin/google-chrome-stable 来在自动模式中提供 /usr/bin/gnome-www-browser (gnome-www-browser)
update-alternatives: 使用 /usr/bin/google-chrome-stable 来在自动模式中提供 /usr/bin/google-chrome (google-chrome)
正在处理用于 gnome-menus (3.13.3-6ubuntu5) 的触发器 ...
正在处理用于 desktop-file-utils (0.23-1ubuntu3) 的触发器 ...
正在处理用于 mime-support (3.60ubuntu1) 的触发器 ...
正在处理用于 man-db (2.7.6.1-2) 的触发器 ...

三、启动软件

$  /usr/bin/google-chrome-stable

安装chromedriver

在google chrome中打开https://chromedriver.storage.googleapis.com/index.html,选择google chrome对应的chromedriver版本https://sites.google.com/a/chromium.org/chromedriver。在这里直接选择了最新版google chrome所能选取的最新版chromedriver。

1.解压下载的chromedriver_linux64.zip

2.$ sudo mv chromedriver /usr/bin

3.$ chromedriver

安装Selenium

1.$ pip3 install selenium

2.如果报错:[Errno 13] 权限不够: '/usr/local/lib/python3.5/dist-packages/selenium'Consider using the `--user` option or check the permissions.

则使用:$ pip3 install --user selenium

测试

1.新建test.py:

from selenium import webdriver

browser = webdriver.Chrome()

2.$ python3 test.py

猜你喜欢

转载自blog.csdn.net/weixin_42353109/article/details/81110708