selenium打开网页,用浏览器edge只能打开空页面

为什么打开的是空页,而不是我输入的地址

import json
import re
import requests
import pickle

from selenium import webdriver

# 创建浏览器对象
driver = webdriver.Edge(executable_path=r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
# 打开网页
url = 'https://www.douyin.com/user/MS4wLjABAAAAF6DBprxchsasOrovWpV5cSeLw1aKKfX1ONlSV5sDExI?modal_id=7107492417036717352'
driver.get(url)

driver = webdriver.Edge(executable_path=r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
这里应该是msedgedriver.exe,而不是msedge.exe
另得保证该地址下有edge浏览器版本对应的driver
可以自己下载https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

该回答引用ChatGPT

该回答引用ChatGPT
您也可以尝试在指定的网页地址前面加上 https:// 或 http:// 协议前缀,以确保地址的正确性。

如果仍然无法正常打开,可以尝试在代码中添加一些异常处理,以更好地了解打开网页失败的原因。

try:
    driver.get(url)
except Exception as e:
    print(f"Failed to open the website: {e}")

很可能是Edge浏览器没有被正确配置或者说找不到,需要确保Edge浏览器的安装位置路径是正确的。

另外,在打开Edge浏览器时,还需要确保Microsoft WebDriver是已经安装且配置完成的,可以在以下链接查看如何配置:

https://docs.microsoft.com/en-us/microsoft-edge/webdriver/

如果仍然不能解决问题,建议您换一种不同的浏览器,例如Chrome或Firefox。