python安装selenium,geckodriver,chromedriver,Selenium IDE

安装浏览器

找到浏览器的版本号

chrome 版本 130.0.6723.92(正式版本) (64 位)

firfox 116.0.3 (64 位),但是后面运行的时候又自动更新到了 127.0.0.8923

安装selenium

> pip install selenium
> pip show selenium
Name: selenium
Version: 4.26.1
Summary: Official Python bindings for Selenium WebDriver
Home-page: https://www.selenium.dev
Author:
Author-email:
License: Apache 2.0
Location: d:\programdata\anaconda3\lib\site-packages
Requires: certifi, trio, trio-websocket, typing_extensions, urllib3, websocket-client
Required-by:

其原理是 selenium 通过浏览器驱动向浏览器发送指令。selenium 目的在于web testing。

selenium 文档

https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

https://github.com/SergeyPirogov/webdriver_manager

安装浏览器驱动的方式有两种

一、手动下载
浏览器 支持的操作系统 维护者 下载 问题追溯
Chromium/Chrome Windows/macOS/Linux Google 下载 Issues
Firefox Windows/macOS/Linux Mozilla 下载 Issues
Edge Windows/macOS/Linux Microsoft 下载 Issues
Internet Explorer Windows Selenium Project 下载 Issues
Safari macOS High Sierra and newer Apple 内置 Issues

备注:Opera驱动不再适用于Selenium的最新功能,目前官方不支持。

将下载的压缩包解压,然后添加到环境变量, 确保可以直接使用命令访问到

firefox驱动下载

firefox的驱动是geckodriver,仓库地址为:https://github.com/mozilla/geckodriver

下载 https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-win64.zip

geckodriver.exe --version

geckodriver 0.34.0 (c44f0d09630a 2024-01-02 15:36 +0000)

The source code of this program is available from
testing/geckodriver in https://hg.mozilla.org/mozilla-central.

This program is subject to the terms of the Mozilla Public License 2.0.
You can obtain a copy of the license at https://mozilla.org/MPL/2.0/.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值