简体   繁体   English

无法使用 selenium 打开 chrome 配置文件

[英]Cant open chrome profile with selenium

I'm making a Whatsapp bot, but is doesn't let me open Whatssapp web without scanning the QR code.我正在制作一个 Whatsapp 机器人,但不允许我在不扫描二维码的情况下打开 Whatssapp web。 I have seen other questions on Stackoverflow with the same problem.我在 Stackoverflow 上看到了同样问题的其他问题。 It says that you need to open your chrome profile with chrome.它说你需要用 chrome 打开你的 chrome 配置文件。

I have already tried to update Selenium, Pip, Pycharm etc, but it still doesn't work.我已经尝试更新 Selenium、Pip、Pycharm 等,但仍然无效。 Also, tried it with user-data-dir.另外,尝试使用 user-data-dir。 But still nothing.但还是一无所获。

With chrome://version you can find the profile path of your chrome profile i copied the path and add it as an argument but still can't open my chrome profile with Selenium.使用 chrome://version 你可以找到你的 chrome 配置文件的配置文件路径我复制了路径并将其添加为参数但仍然无法使用 Selenium 打开我的 chrome 配置文件。

Also, made a second chrome profile and stored the folder somewhere else on my PC but that also doesn't work.此外,制作了第二个 chrome 配置文件并将文件夹存储在我电脑上的其他地方,但这也不起作用。 Tried i lot of things but nothing seems to work, anybody else got these problems.尝试了很多东西,但似乎没有任何效果,其他人也遇到了这些问题。

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

options = webdriver.ChromeOptions()
options.add_argument("/Users/maxbenenn/Library/Application Support/Google/Chrome")
options.add_argument("--profile-directory=Profile 2")

driver = webdriver.Chrome(service=Service("/Users/maxbenenn/Desktop/chromedriver"), options = options)
driver.get("https://web.whatsapp.com/")

Mention your profile path like below:提及您的个人资料路径,如下所示:

from selenium.webdriver.chrome.service import Service

options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=C:\\Users\\<User>\\AppData\\Local\\Google\\Chrome\\User Data\\")
options.add_argument("--profile-directory=Default")  #if you want to use default profile, otherwise mention that specific profile's dir name here

driver = webdriver.Chrome(service=Service("/Users/maxbenenn/Desktop/chromedriver"), options = options)
driver.get("https://web.whatsapp.com/")

https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/820 https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/820

Here is the solution to your problem.这是您的问题的解决方案。 Use undetected_chromedriver (powered by selenium) to sign in to google profile.使用undetected_chromedriver (由 selenium 提供支持)登录到 google 个人资料。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM