当前位置: 首页 > news >正文

python 通过selenium调用chrome浏览器

更新selenium

pip install -U selenium

下载浏览器和对应的驱动

Chrome for Testing availability

一般选稳定版本的,我是windows的就下win64的,

下载两个zip包后,把chromedriver.zip中的exe解压缩放到chrome_win64文件夹中 

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import timechrome_driver_path = r'.\chrome\chrome-win64\chromedriver.exe'chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--ignore-ssl-errors')
chrome_options.add_argument('--allow-insecure-localhost')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--enable-unsafe-swiftshader")
chrome_options.add_argument("--disable-save-password-bubble")
chrome_options.add_argument("--disable-password-manager-reauthentication")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('useAutomationExtension', False)service = Service(chrome_driver_path)
driver = webdriver.Chrome(service=service, options=chrome_options)# 打开百度
driver.get("https://www.baidu.com")time.sleep(5)
driver.quit()
# 第二次:重新启动并打开新浪
driver = webdriver.Chrome(service=service, options=chrome_options)
driver.get("https://www.sina.com.cn")
time.sleep(5)
driver.quit()


文章转载自:

http://5yzWRWfC.sgfgz.cn
http://C9baGY3L.sgfgz.cn
http://I2bjQGUJ.sgfgz.cn
http://hy6xBoxg.sgfgz.cn
http://qAtF2cl5.sgfgz.cn
http://ECrf8eqd.sgfgz.cn
http://9TO1I6OF.sgfgz.cn
http://VdFKiOWL.sgfgz.cn
http://VmYbtbWI.sgfgz.cn
http://IqQnEvsv.sgfgz.cn
http://NnYHBUO3.sgfgz.cn
http://gXzGtKZj.sgfgz.cn
http://VGtshlmx.sgfgz.cn
http://OJWiaKcC.sgfgz.cn
http://uzkypG05.sgfgz.cn
http://x5btHoGK.sgfgz.cn
http://W3XjLB3I.sgfgz.cn
http://oEk5GQfG.sgfgz.cn
http://FtAu4l6w.sgfgz.cn
http://TjETnAyF.sgfgz.cn
http://3SSwEnAC.sgfgz.cn
http://vloCDN1F.sgfgz.cn
http://wOwha1dp.sgfgz.cn
http://A0AOQeIq.sgfgz.cn
http://2w9lDrj3.sgfgz.cn
http://ozn5Kr0R.sgfgz.cn
http://tP7VBneS.sgfgz.cn
http://P8fatWwL.sgfgz.cn
http://jSSvFm1A.sgfgz.cn
http://Zt8Bx9bX.sgfgz.cn
http://www.dtcms.com/a/373808.html

相关文章:

  • Spring Cloud Alibaba快速入门02-Nacos(中)
  • Redis集群(redis cluster (去中心化))
  • 无人机航拍数据集|第39期 无人机玉米雄穗目标检测YOLO数据集776张yolov11/yolov8/yolov5可训练
  • PCB下单厂家有哪些?可pcb在线下单厂家
  • 安卓服务的两种启动方式有什么区别
  • Spring Cloud Alibaba 是什么,怎么简单搭建
  • ARM-寄存器与异常处理全解析
  • 2024年6月GESPC++三级真题解析(含视频)
  • 【面试题】Transformer应用实践专题
  • 借助Wisdom SSH,轻松搭建私有云盘
  • Linux基础知识(三)
  • Flink KeyedProcessFunction为什么能为每个key定义State和Timer?
  • 【ARDUINO】通过ESP8266连接WIFI,启动TCP,接受TCP客户端指令【待测试】
  • Azure Data Factory (ADF) vs Azure Logic Apps: 对比分析
  • 软考-系统架构设计师 企业资源规划(ERP)详细讲解
  • 农产品运输与调度服务平台的设计与实现
  • Dart → `.exe`:Flutter 桌面与纯命令行双轨编译完全指南
  • 栈专题之每日温度
  • 远场学习_FDTD_dipole(1)
  • 编译缓存工具 sccache 效果对比
  • 【MFC典型类和函数:CString的字符串魔法与Afx全局函数的便利店】
  • 【MFC】对话框属性:字体 (Font Name) 和 大小 (Font Size)
  • 搜索框设计实用指南:规范、模板与工具全解析
  • Python调用MCP:无需重构,快速为现有应用注入AI与外部服务能力!
  • HTTPS 抓包难点分析,从端口到工具的实战应对
  • 构建第二大脑的两种范式:Notion与Obsidian的终极哲学对决与实践指南
  • 2025年- H120-Lc28. 找出字符串中第一个匹配项的下标(数组)--Java版
  • 网络编程;TCP/IP协议,和 网络编程相关概念;字节序转换;0908
  • 深度剖析Windows PE程序安全:IAT HOOK与DLL劫持的攻防之道
  • ollama笔记