无法使用selenium python打开URL,但浏览器已成功打开

无法使用selenium python打开URL,但浏览器已成功打开,python,python-3.x,selenium,selenium-webdriver,webdriver,Python,Python 3.x,Selenium,Selenium Webdriver,Webdriver,此代码仅使用我的个人资料打开chromedriver,但无法重定向到链接,而不是编写以下内容: from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys import time import datetime ch_options = webdriver.ChromeOptions()

此代码仅使用我的个人资料打开chromedriver,但无法重定向到链接,而不是编写以下内容:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import datetime


ch_options = webdriver.ChromeOptions()
ch_options.add_argument("--user-data-dir=C:\\Users\\Dossy\\AppData\\Local\\Google\\Chrome\\User Data")


chrome = webdriver.Chrome(options=ch_options)

chrome.get("https://www.google.com/")
您可以直接给出路径

ch_options = webdriver.ChromeOptions()
ch_options.add_argument("--user-data-dir=C:\\Users\\Dossy\\AppData\\Local\\Google\\Chrome\\User Data")
比如:


您的浏览器将打开,它也会将您重定向到该链接。

而不是写入以下内容:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import datetime


ch_options = webdriver.ChromeOptions()
ch_options.add_argument("--user-data-dir=C:\\Users\\Dossy\\AppData\\Local\\Google\\Chrome\\User Data")


chrome = webdriver.Chrome(options=ch_options)

chrome.get("https://www.google.com/")
您可以直接给出路径

ch_options = webdriver.ChromeOptions()
ch_options.add_argument("--user-data-dir=C:\\Users\\Dossy\\AppData\\Local\\Google\\Chrome\\User Data")
比如:


您的浏览器将打开,它也会将您重定向到链接。

请使用正确的驱动程序路径尝试此操作

chrome = webdriver.Chrome('C:\\Users\\Lucky\\Downloads\\.zip\\chromedriver.exe')

使用正确的驱动程序路径尝试此操作

chrome = webdriver.Chrome('C:\\Users\\Lucky\\Downloads\\.zip\\chromedriver.exe')

让它变得如此简单和简短: 确保正确添加chrome驱动程序路径

从selenium导入webdriver 从selenium.webdriver.chrome.options导入选项 从selenium.webdriver.common.keys导入密钥 导入时间 导入日期时间 PATH=rC:\ProgramFilesx86\chromedriver.exe下载驱动程序的路径 driver=webdriver.ChromePATH 驾驶员gethttps://www.google.com
希望这能奏效

让它变得如此简单和简短: 确保正确添加chrome驱动程序路径

从selenium导入webdriver 从selenium.webdriver.chrome.options导入选项 从selenium.webdriver.common.keys导入密钥 导入时间 导入日期时间 PATH=rC:\ProgramFilesx86\chromedriver.exe下载驱动程序的路径 driver=webdriver.ChromePATH 驾驶员gethttps://www.google.com
希望这能奏效

如果您在第一个解决方案中遇到问题,请尝试以下操作: chrome驱动程序路径的第一个副本:

然后,转到这台电脑,右键单击它,然后转到属性:

之后进入高级系统设置:

然后,单击环境变量

然后,在系统变量中单击路径,然后单击编辑:

然后,单击新建:

完成后,使用\chromedriver.exe粘贴复制的路径,然后单击“确定”:

然后在所有选项卡上单击“确定” 就这样 现在试试看
如果您在第一个解决方案中仍有问题,请进行注释。

如果您在第一个解决方案中有问题,请尝试以下操作: chrome驱动程序路径的第一个副本:

然后,转到这台电脑,右键单击它,然后转到属性:

之后进入高级系统设置:

然后,单击环境变量

然后,在系统变量中单击路径,然后单击编辑:

然后,单击新建:

完成后,使用\chromedriver.exe粘贴复制的路径,然后单击“确定”:

然后在所有选项卡上单击“确定” 就这样 现在试试看
如果您在这方面仍然有问题,请发表评论。

我尝试了chrome=webdriver.chrome'C:\\Users\\Lucky\\Downloads\.zip\\chromedriver.exe'但它不使用我的个人资料,它使用的是来宾帐户我尝试了chrome=webdriver.chrome'C:\\Users\\Lucky\\Downloads\.zip\\chromedriver.exe'但它不使用我的个人资料,它使用来宾帐户我尝试了PATH=rC:\PATH\to\chromedriver.exe,但没有使用我的Chrome用户配置文件,而是使用Chrome来宾帐户我尝试了PATH=rC:\PATH\to\chromedriver.exe,但没有使用我的Chrome用户配置文件,相反,它使用的是Chrome来宾帐户。如果有问题,请尝试此操作。如果有问题,请尝试此操作。