当前位置: 首页 > 知识库问答 >
问题:

使用python和selenium自动谷歌登录显示“此浏览器或应用可能不安全”

景稳
2023-03-14

我试过用Gmail或任何谷歌服务登录,但它显示以下“此浏览器或应用程序可能不安全”消息:

我还尝试在acc中启用不太安全的应用程序,但没有成功。然后我建立了一个新的谷歌账户,它和我一起工作。但不是和我以前的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() 

共有3个答案

简意
2023-03-14


注意:在name==main中缩进代码,就像我所做的那样,只有这样程序才能正常工作

import undetected_chromedriver as uc
from time import sleep
from selenium.webdriver.common.by import By


if __name__ == '__main__':
    
    driver = uc.Chrome()
    driver.get('https://accounts.google.com/')

    # add email
    driver.find_element(By.XPATH, '//*[@id="identifierId"]').send_keys(YOUR EMAIL)
    driver.find_element(By.XPATH, '//*[@id="identifierNext"]/div/button/span').click()
    sleep(3)
    driver.find_element(By.XPATH, '//*[@id="password"]/div[1]/div/div[1]/input').send_keys(YOUR PASSWORD)
    driver.find_element(By.XPATH, '//*[@id="passwordNext"]/div/button/span').click()
    sleep(10)


庞瀚
2023-03-14

这对我有用。我从GitHub找到了解决方案。

   from selenium import webdriver
   from selenium_stealth import stealth

   options = webdriver.ChromeOptions()
   options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36")
   options.add_experimental_option("excludeSwitches", ["enable-automation"])
   options.add_experimental_option('useAutomationExtension', False)
   options.add_argument('--disable-blink-features=AutomationControlled')
   driver = webdriver.Chrome(options=options)
   stealth(driver,
        languages=["en-US", "en"],
        vendor="Google Inc.",
        platform="Win32",
        webgl_vendor="Intel Inc.",
        renderer="Intel Iris OpenGL Engine",
        fix_hairline=True,
        )
   driver.get("https://www.google.com")
常鸿朗
2023-03-14

首先,不要使用chrome和chromedriver。你需要使用Firefox。(如果未安装)下载并安装Firefox。使用普通Firefox登录谷歌。

你需要向谷歌网站证明你不是机器人。您可以使用如下代码:

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)

这可以帮助你找到你的个人资料位置。

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

你可以这样愚弄谷歌。这对我也有用。我非常努力地做到这一点。希望你也能解决这个问题。

 类似资料:
  • 我正试图用selenium登录谷歌,但我一直收到一个错误:“这个浏览器或应用程序可能不安全。” 我用来登录的功能是: 这和https://stackoverflow.com/questions/59433453/unable-to-log-into-google-account-in-selenium-chrome-driver和https://stackoverflow.com/question

  • 所以我一直在尝试通过selenium访问我的gmail或Google Colab笔记本。我没有通过电子邮件和密码进行身份验证,而是使用已保存的Google Chrome配置文件启动chromedriver,但它会抛出以下内容: 我已经尝试了以前行之有效的每一个解决方案,但现在不起作用了,我尝试的一些解决方案有: 禁用双因素身份验证 允许不太安全的应用程序访问 禁用我知道的每个标志,让网站检测到该网

  • 问题内容: 我正在尝试使用selenium登录到google,但不断收到错误消息“此浏览器或应用可能不安全”。 我用来登录的功能是: 我尝试使用chrome和firefox网络驱动程序,但均无法正常工作。我也尝试过这样做也没有帮助。 这使我认为登录页面也许可以检测到我在自动化环境中运行。我尝试过这种解决方案,该解决方案使该应用程序[无法在Web驱动程序中运行:网站可以检测到您何时在chromedr

  • 我在selenium上遇到了这个问题,我尝试运行下面的代码,但出现了以下错误:https://i.postimg.cc/VNd3F4rm/u2zrn.jpg . 我“登录谷歌”的图片:https://i.stack.imgur.com/w3POX.png(如你所见,“应用程序密码”在我看来并不存在) 我已经尝试禁用帐户设置中的“不太安全的应用”部分,并检查JavaScipt是否已激活,但没有成功。

  • 我试图通过使用硒从收件箱下载附件来自动化gmail。但是,它向我显示了这个错误“此浏览器或应用程序可能不安全”。我环顾四周,发现OAuth将解决这个问题。但是,我不知道如何使用它,也不知道它是否是正确的工具。有人能帮我解决这个错误吗?OAuth是正确的工具吗?使用任何其他浏览器都会解决这个问题吗? 错误:此浏览器或应用可能不安全。了解更多信息尝试使用不同的浏览器。如果您已经在使用受支持的浏览器,则

  • 我必须使用selenium脚本登录gmail帐户,但我收到了错误消息 正如从其他来源读到的,谷歌不允许使用自动化脚本登录 机器:MacOS编程语言:Java 有人知道怎么解决吗?