郓城县建设局网站,店铺网络推广有哪些渠道,重庆网站推广运营,如何增加网站外链网上很多教程都是在线安装chrome#xff0c;这样安装了最新稳定的chrome#xff0c;可惜我遇到chromdriver的版本跟上 chrome#xff0c;为了早日实现在centos服务selenium自动化#xff0c;不可能去等待 chromdriver 更新#xff0c;只能 chrome进行降版本来离线安装。花…网上很多教程都是在线安装chrome这样安装了最新稳定的chrome可惜我遇到chromdriver的版本跟上 chrome为了早日实现在centos服务selenium自动化不可能去等待 chromdriver 更新只能 chrome进行降版本来离线安装。花了几个小时找资源终于找到一个可用的
安装chrome
一、下载安装包链接: https://pan.baidu.com/s/1ScyMB54eoFfGXq7-RapsdA 提取码: amnp 二、安装流程
rpm -ivh vulkan-filesystem-1.1.97.0-1.el7.norch.rpm
rpm -ivh vulkan-1.1.97.0-1.el7.x86_64.rpm
rpm -ivh liberation-narrow-fonts-1.07.2-16.el7.noarch.rpm
rpm -ivh liberation-fonts-1.07.2-16.el7.noarch.rpm
rpm -i google-chrome-stable-current_x86_x64.rpm chromedriver安装
chromedriver下载 在https://npm.taobao.org/mirrors/chromedriver/中下载对应版本的chromedriver上面的chrome对应下面这个版本的
https://cdn.npmmirror.com/binaries/chromedriver/103.0.5060.134/chromedriver_linux64.zip 解压软件可在windows下下载, 解压后再转移过去或unzip chromedriver_linux64.zip 将软件移至对应目录下很重要 mv chromedriver /usr/bin/ 赋权限 chmod x /usr/bin/chromedriver 验证安装完成 直接输入chromedriver 编写python测试chrome以及驱动是否能够正常运行
测试代码test_google.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options# 创建 ChromeOptions 实例启用无头模式
chrome_options Options()
chrome_options.add_argument(--headless)
chrome_options.add_argument(--no-sandbox)
chrome_options.add_argument(--disable-dev-shm-usage)
# 指定 ChromeDriver 的路径根据实际情况修改
chrome_driver_path /usr/bin/chromedriver# 创建 Chrome WebDriver 实例
driver webdriver.Chrome(executable_pathchrome_driver_path, optionschrome_options)# 打开网页
driver.get(https://www.google.com)# 输出网页标题
print(Page title:, driver.title)# 关闭浏览器
driver.quit()
运行成功的结果
python test_google.py
/usr/path/test_google.py:13: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver webdriver.Chrome(executable_pathchrome_driver_path, optionschrome_options) Page title: Google