老实说,在多次尝试解决方案后,谷歌仍然给我这个错误,这让我感到沮丧:
由于有一篇关于这个问题的类似帖子,我想尝试一下https://stackoverflow.com/a/60117617/12556138给出的解决方案,但是无济于事,他提供的解决方案不起作用,因为我尝试过完全做到 ff:
a.添加 ff。我的代码的选项
edge_options.add_argument("--disable-web-security")
edge_options.add_argument("--allow-running-insecure-content")
edge_options.add_argument("--user-data-dir=C:/Users/Mig/AppData/Local/Google/Chrome/User Data/Profile 1")
b.关闭双因素身份验证
c.尝试打开不太安全的应用程序,但我研究发现,从 2022 年 5 月 30 日开始,谷歌已经删除了允许来自不太安全的应用程序连接的选项。您必须在 Google 帐户上启用两步验证并生成应用程序密码123使用Google SMTP服务器或其他需要Google登录的第三方应用程序,这与解决方案b直接矛盾。
d。 JavaScript 在我的 Edge 浏览器中始终处于打开状态
e。还尝试删除浏览器上的所有历史记录和保存的数据
f。尝试在 https://myaccount.google.com/
中远程从所有设备中注销我的 Google 帐户以下也是我的错误信息:
[<some token>/184906.747:ERROR:chrome_browser_cloud_management_controller.cc(162)] Cloud management controller initialization aborted as CBCM is not enabled.
[<some token>/184906.769:ERROR:assistance_home_client.cc(32)] File path C:\Users\Mig\AppData\Local\Temp\scoped_dir1308_592920665\Default
DevTools listening on ws://127.0.0.1:<some token>
[<some token>/184908.140:ERROR:fallback_task_provider.cc(124)] Every renderer should have at least one task provided by a primary task provider. If a "Renderer" fallback task is shown, it is a bug. If you have repro steps, please file a new bug and tag it as a dependency of crbug.com/739782.
[<some token>/184909.398:ERROR:smartscreen_dns_resolver.cc(110)] SmartScreenDnsResolver::OnComplete Error: -7 DidTimeOut: 1 URL: https://www.linkedin.com/mynetwork/invite-connect/connections/
done!
[<some token>/184912.991:ERROR:gpu_disk_cache.cc(216)] Failed to create blob cache entry: -2
(gmail-automations) D:\Projects\To Github\auto-job-app-sender>[<some token>/184918.305:ERROR:device_event_log_impl.cc(222)] [18:49:18.305] Bluetooth: bluetooth_adapter_winrt.cc:1058 Getting Default Adapter failed.
下面是我的主要Python脚本:
def main():
# # if using chrome
# chrome_options = ChromeOptions()
# chrome_options.add_experimental_option('detach', True)
# service = ChromeService(executable_path=ChromeDriverManager().install())
# driver = webdriver.Chrome(service=service, options=chrome_options)
# if using edge
edge_options = EdgeOptions()
edge_options.add_experimental_option('detach', True)
# edge_options.add_argument("--disable-web-security")
# edge_options.add_argument("--allow-running-insecure-content")
# edge_options.add_argument("--user-data-dir=C:/Users/Mig/AppData/Local/Google/Chrome/User Data/Profile 1")
# edge_options.add_argument("--profile-directory=Default")
service = EdgeService(executable_path=EdgeChromiumDriverManager().install())
driver = webdriver.Edge(service=service, options=edge_options)
links_to_connections = collect_links_to_connections(driver=driver, link="https://www.linkedin.com/mynetwork/invite-connect/connections/")
# collect_recruiter_info(driver, links)
我还有一位同事通过他的谷歌帐户登录了他的链接,请注意他的帐户启用了双因素身份验证,因此这就引出了问题。 我的谷歌帐户或我的代码有什么问题,即使我禁用了双因素身份验证,也不允许我使用 Selenium Web 驱动程序登录我的谷歌帐户?
我可以在我这边重现这个问题。我认为我们不能使用 selenium WebDriver 来控制 LinkedIn Google 帐户中的自动登录。 Google 应该检测到使用 WebDriver,因此会阻止进一步的操作。
您可以使用登录到您的 LinkedIn Google 帐户的 Edge 个人资料作为解决方法。然后您只需进入网址https://www.linkedin.com/mynetwork/invite-connect/connections/,无需再次登录。
您可以在 edge://version/ 中找到配置文件路径,并在代码中使用该配置文件,如下所示:
edge_options.add_argument("user-data-dir=C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\Edge\\User Data")
edge_options.add_argument("profile-directory=Profile 1")