使用python和selenium自动化谷歌登录显示“"这个浏览器或应用程序可能不安全“" [英] Automation Google login with python and selenium shows ""This browser or app may be not secure""

查看:258
本文介绍了使用python和selenium自动化谷歌登录显示“"这个浏览器或应用程序可能不安全“"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已尝试使用 Gmail 或任何 Google 服务登录,但显示以下内容此浏览器或应用程序可能不安全";留言:

I've tried login with Gmail or any Google services but it shows the following "This browser or app may not be secure" message:

我也尝试过在我的 acc 中启用安全性较低的应用程序等选项,但没有奏效.然后我创建了一个新的谷歌帐户,它对我有用.但不是我的旧帐户.

I also tried to do options like enable less secure app in my acc but it didn't work. then I made a new google account and it worked with me. but not with my old acc.

  1. 我该如何解决这个问题?
  2. 如何在普通 Chrome 浏览器中打开 selenium 而不是由自动化软件控制的浏览器?

    这是我的代码

    from selenium.webdriver import Chrome
    from selenium.webdriver.chrome.options import Options


    browser = webdriver.Chrome()
    browser.get('https://accounts.google.com/servicelogin')
    search_form = browser.find_element_by_id("identifierId")
    search_form.send_keys('mygmail')
    nextButton = browser.find_elements_by_xpath('//*[@id ="identifierNext"]') 
    search_form.send_keys('password')
    nextButton[0].click() 

推荐答案

首先不要使用 chrome 和 chromedriver.您需要使用 Firefox.(如果未安装)下载并安装 Firefox.使用普通 Firefox 登录 Google.

First of all don't use chrome and chromedriver. You need to use Firefox.(if not installed) Download and install Firefox. Login to Google with normal Firefox.

您需要向 Google 网站表明您不是机器人.您可以使用这样的代码:

You need to show the Google site that you are not a robot. You can use code like this:

from selenium import webdriver
import geckodriver_autoinstaller
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

geckodriver_autoinstaller.install()

profile = webdriver.FirefoxProfile(
    '/Users/<user name>/Library/Application Support/Firefox/Profiles/xxxxx.default-release')

profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
desired = DesiredCapabilities.FIREFOX

driver = webdriver.Firefox(firefox_profile=profile,
                           desired_capabilities=desired)

可以帮助您找到您的个人资料位置.

This can help you find your profile location.

实际上只有一个原因,chromedriver 是由 Google 编码的.他们可以很容易地理解它是否是机器人.但是当我们用 Firefox 添加用户数据时,他们无法理解是否有机器人.

Actually there is only one reason, chromedriver was coded by Google. They can easily understand if it is a bot or not. But when we add user data with Firefox, they cannot understand if there is a bot or not.

你可以这样欺骗谷歌.它也对我有用.我非常努力地做到这一点.希望它也能在你身上得到解决.

You can fool Google like this. It worked for me too. I tried very hard to do this. Hope it will be resolved in you too.

这篇关于使用python和selenium自动化谷歌登录显示“"这个浏览器或应用程序可能不安全“"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆