mac+python3+selenium 4

下载自己的版本

ChromeDriver - WebDriver for Chrome - Downloadshttps://chromedriver.chromium.org/downloads

https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.jsonhttps://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json

把下载好的程序 Google Chrome for Testing.app 解压到 /usr/local/bin/

双击打开试一下,如果打不开,
sudo xattr -d com.apple.quarantine /拖动APP

然后重命名为 chromedriver

.app扩展名也去掉

python 复制代码
from selenium import webdriver

from time import sleep
from selenium.webdriver.common.by import By

# 启动浏览器驱动
driver = webdriver.Chrome()

# 访问url
driver.get('https://www.baidu.com')

# 定位元素
el = driver.find_element(By.ID, 'kw')

# 执行自动化操作
el.send_keys('热搜')
driver.find_element(By.ID, 'su').click()
# 休眠5秒
sleep(5)

# 关闭浏览器并释放进程资源
# driver.quit()
相关推荐
RSABLOCKCHAIN5 小时前
AI Agents in LangGraph-2
人工智能·python
WA内核拾荒者6 小时前
WhatsApp 账号异常检测的自动化告警系统设计
数据库·python·自动化
码流怪侠7 小时前
【GitHub】Bend:让 GPU 并行编程像写 Python 一样简单
python·github
2401_894915538 小时前
GEO 搜索优化完整源码从零部署:环境配置、集群搭建全流程
开发语言·python·tcp/ip·算法·unity
zhiSiBuYu05179 小时前
Python3 模块开发与应用实战指南
python
databook10 小时前
用方差阈值过滤掉“惰性特征”
python·机器学习·scikit-learn
Freak嵌入式10 小时前
MCU 低功耗模式解析:时钟门控、电源门控、深度休眠
人工智能·python·单片机·嵌入式硬件·开源·依赖倒置原则·micropython
weixin_BYSJ198711 小时前
springboot校园自习室管理小程序---附源码32142
java·javascript·spring boot·python·django·flask·php
2501_9159214311 小时前
iOS开发环境搭建详解 Xcode 配置与快蝎轻量级工具选择
ide·vscode·macos·ios·个人开发·xcode·敏捷流程