|
7鱼币
如图所示我在这个链接地址下载了对应的浏览器和 驱动
https://googlechromelabs.github.io/chrome-for-testing/#stable
并把它放在了桌面
使用了以下代码 打开百度
from selenium import webdriver
# 创建 ChromeDriver 选项
chrome_options = webdriver.ChromeOptions()
# 指定谷歌浏览器的路径
chrome_binary_path = r'C:\Users\huawei\Desktop\chrome-win64\chrome.exe' # 将路径替换为你实际的谷歌浏览器路径
chrome_options.binary_location = chrome_binary_path
# 指定 ChromeDriver 的路径
chrome_driver_path = r'C:\Users\huawei\Desktop\chromedriver-win64\chromedriver.exe' # 将路径替换为你实际的 ChromeDriver 路径
# 使用指定的 ChromeDriver 路径和选项创建 Chrome 实例
driver = webdriver.Chrome(options=chrome_options)
# 打开百度网站
driver.get("https://www.baidu.com")
# 关闭浏览器
driver.quit()
浏览器没有打开 并且pcharm 显示运行中 这个是为什么呢
最后一行你把浏览器关了
由于程序结束了,所以打开的chrome窗口也会关闭,你可以time.sleep
|
最佳答案
查看完整内容
最后一行你把浏览器关了
由于程序结束了,所以打开的chrome窗口也会关闭,你可以time.sleep
|