<small id='4yjFk'></small><noframes id='4yjFk'>

      • <bdo id='4yjFk'></bdo><ul id='4yjFk'></ul>
      <i id='4yjFk'><tr id='4yjFk'><dt id='4yjFk'><q id='4yjFk'><span id='4yjFk'><b id='4yjFk'><form id='4yjFk'><ins id='4yjFk'></ins><ul id='4yjFk'></ul><sub id='4yjFk'></sub></form><legend id='4yjFk'></legend><bdo id='4yjFk'><pre id='4yjFk'><center id='4yjFk'></center></pre></bdo></b><th id='4yjFk'></th></span></q></dt></tr></i><div id='4yjFk'><tfoot id='4yjFk'></tfoot><dl id='4yjFk'><fieldset id='4yjFk'></fieldset></dl></div>

      <legend id='4yjFk'><style id='4yjFk'><dir id='4yjFk'><q id='4yjFk'></q></dir></style></legend>
      1. <tfoot id='4yjFk'></tfoot>

        由于“此浏览器或应用程序可能不安全",无

        时间:2023-09-02
        <i id='vduKN'><tr id='vduKN'><dt id='vduKN'><q id='vduKN'><span id='vduKN'><b id='vduKN'><form id='vduKN'><ins id='vduKN'></ins><ul id='vduKN'></ul><sub id='vduKN'></sub></form><legend id='vduKN'></legend><bdo id='vduKN'><pre id='vduKN'><center id='vduKN'></center></pre></bdo></b><th id='vduKN'></th></span></q></dt></tr></i><div id='vduKN'><tfoot id='vduKN'></tfoot><dl id='vduKN'><fieldset id='vduKN'></fieldset></dl></div>
          <tfoot id='vduKN'></tfoot>

        • <legend id='vduKN'><style id='vduKN'><dir id='vduKN'><q id='vduKN'></q></dir></style></legend>

              <tbody id='vduKN'></tbody>

              <small id='vduKN'></small><noframes id='vduKN'>

                  <bdo id='vduKN'></bdo><ul id='vduKN'></ul>
                  本文介绍了由于“此浏览器或应用程序可能不安全",无法使用 selenium 自动化登录 Google.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用 selenium 登录 Google,但我不断收到此浏览器或应用程序可能不安全"的错误消息.

                  I am trying to login to google with selenium and I keep getting the error that "This browser or app may not be secure."

                  我用来登录的功能是:

                  async function loginToChrome(driver, username, password) {
                    await driver.get("https://accounts.google.com/signin");
                    await driver.sleep(1000);
                    let email_phone = await driver.findElement(
                      By.xpath("//input[@id='identifierId']")
                    );
                    await email_phone.sendKeys(username);
                    await driver.findElement(By.id("identifierNext")).click();
                    await driver.sleep(1000);
                  
                    let passEl = await driver.findElement(By.xpath("//input[@name='password']"));
                    await passEl.sendKeys(password);
                    await driver.findElement(By.id("passwordNext")).click();
                    await driver.sleep(1000);
                  }
                  

                  这是同样的问题https://stackoverflow.com/questions/59433453/无法登录到-google-account-in-selenium-chrome-driver和https://stackoverflow.com/questions/59276975/couldnt-sign-you-in-this-browser-or-app-may-be-insecure-python-selenium-chrome

                  我尝试使用 chrome 和 firefox 网络驱动程序,但都不起作用.我也尝试过 .excludeSwitches(['enable-automation']) 也没有帮助.

                  I have tried using both the chrome and firefox web drivers and both don't work. I have also tried doing .excludeSwitches(['enable-automation']) which also didn't help.

                  这让我觉得登录页面可能会检测到我在自动化环境中运行.我尝试了这个解决方案,它可以隐藏应用程序在网络驱动程序中运行:当您使用 selenium 和 chromedriver 时,网站可以检测到吗?

                  This made me think that maybe the sign-in page could detect that I was running in an automated environment. I tried this solution that would hide that the app is running in a web driver: Can a website detect when you are using selenium with chromedriver?

                  我还查看了 User-Agent 是否是问题所在,但我发现它与我的常规 chrome 相同.

                  I have also looked into the User-Agent to see if that was the problem but what I have found is that it is identical to my regular chrome one.

                  所有这些都没有奏效,这让我陷入了困境.我见过一些解决方案,说要使用正常安装的 chrome 中已经创建的用户配置文件,但这不适用于我的用例.

                  All of this has not worked which makes leaves me stuck. I have seen solutions that say to use an already created user profile from your normal installation of chrome, but this wouldn't work for my use case.

                  有没有人找到解决这个问题的方法?我已经找了好几个小时,却空手而归.

                  Has anyone found the solution to this? I have been searching for hours and have come up empty-handed.

                  看来这件事最近引起了很多关注.我找到了一个解决方案,让我可以继续使用自动化客户端而不会遇到太多问题.切换到 Puppeteer.查看这些包:

                  It seems like this has been getting a lot of attention recently. I found a solution that allowed me to continue to use an automated client without having too many problems. Switching to Puppeteer. Look into these packages:

                      "puppeteer",
                      "puppeteer-extra",
                      "puppeteer-extra-plugin-stealth"
                  

                  编辑 2:我看到这最近引起了很多关注.我找到了我最终用来登录的代码.我使用 puppeteer 而不是 selenium 来做到这一点

                  EDIT 2: I have seen this get a lot of attention recently. I found the code that I ended up using to login. I used puppeteer instead of selenium to do this

                  async function login(
                    page: Page,
                    username: string,
                    password: string,
                    backup: string
                  ) {
                    await page.goto("https://accounts.google.com/");
                  
                    await page.waitForNavigation();
                  
                    await page.waitForSelector('input[type="email"]');
                    await page.click('input[type="email"]');
                  
                    await page.waitForNavigation();
                  
                    //TODO : change to your email
                    await page.type('input[type="email"]', username);
                    await page.waitForSelector("#identifierNext");
                    await page.click("#identifierNext");
                  
                    await page.waitFor(1000);
                  
                    await page.waitForSelector('input[type="password"]');
                    await page.click('input[type="password"]');
                    await page.waitFor(500);
                    //TODO : change to your password
                    await page.type('input[type="password"]', password);
                  
                    await page.waitForSelector("#passwordNext");
                    await page.click("#passwordNext");
                    await page.waitForNavigation();
                  }
                  

                  推荐答案

                  以下方法也适用于我:1.尝试用你的google账号登录stackoverflow2. 登录后,进入邮箱

                  The followings work me as well: 1. try to login stackoverflow with your google account 2. once login, go to the email

                  解决办法

                       WebDriver driver;
                      System.setProperty("webdriver.chrome.driver", "chromeDriver/chromedriver.exe");
                      driver = new ChromeDriver();
                       GeneralClass te =  new GeneralClass ();
                  
                      driver.get("https://accounts.google.com/signin/oauth/identifier?client_id=717762328687-iludtf96g1hinl76e4lc1b9a82g457nn."
                              + "apps.googleusercontent.com&as=JS6BM8cjL-8j9votansdkw&destination=https%3A%2F%2Fstackauth"
                              + ".com&approval_state=!ChRoYWVvLUlNMk5hSXJWUGlaSVl2WBIfc3lSa0lueENpb29lSU5vbEVpbVNxcUZGaGNkSEJoYw%E2%88%99AJDr988AAAAAXlBKc7PzEomxSzgNqd4wLptVlf0Ny3Qx&oauthgdpr=1&xsrfsig=ChkAeAh8T8JNDxCf2Zah5fb_rQ55OMiF8KmMEg5hcHByb3ZhbF9zdGF0ZRILZGVzdGluYXRpb24SBXNvYWN1Eg9vYXV0aHJpc2t5c2NvcGU&flowName=GeneralOAuthFlow");
                       te.waitingForElementSendingKey(driver, By.id("identifierId"), "XXXXXXXX@gmail.com");
                       te.waitingForElementForClickOnly(driver, By.id("identifierNext"));
                       te.waitingForElementSendingKey(driver,By.name("password"), "PASSSWORD");
                       te.waitingForElementForClickOnly(driver, By.id("passwordNext"));
                       Thread.sleep(1500);
                       driver.get("https://mail.google.com/mail/u/0/#inbox");
                  

                  谢谢

                  这篇关于由于“此浏览器或应用程序可能不安全",无法使用 selenium 自动化登录 Google.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:检查一个多边形点是否在传单中的另一个内部 下一篇:如何使用python更改html行代码

                  相关文章

                  最新文章

                • <small id='1kzPE'></small><noframes id='1kzPE'>

                  <legend id='1kzPE'><style id='1kzPE'><dir id='1kzPE'><q id='1kzPE'></q></dir></style></legend>
                  1. <tfoot id='1kzPE'></tfoot>
                      <bdo id='1kzPE'></bdo><ul id='1kzPE'></ul>
                    <i id='1kzPE'><tr id='1kzPE'><dt id='1kzPE'><q id='1kzPE'><span id='1kzPE'><b id='1kzPE'><form id='1kzPE'><ins id='1kzPE'></ins><ul id='1kzPE'></ul><sub id='1kzPE'></sub></form><legend id='1kzPE'></legend><bdo id='1kzPE'><pre id='1kzPE'><center id='1kzPE'></center></pre></bdo></b><th id='1kzPE'></th></span></q></dt></tr></i><div id='1kzPE'><tfoot id='1kzPE'></tfoot><dl id='1kzPE'><fieldset id='1kzPE'></fieldset></dl></div>