首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用playwright登录google帐户?

如何使用playwright登录google帐户?
EN

Stack Overflow用户
提问于 2020-12-04 14:48:54
回答 2查看 1.1K关注 0票数 1

我有以下源代码,并在headful模式下运行。我可以输入电子邮件地址。但是,在那之后,会出现这样的信息:“can't sign you in.For your protection,you‘t sign you in.For your protection,you can But from this device.稍后再试,或者从其他设备登录”。

我需要设置额外的头部或其他东西吗?

这是我的源代码。

代码语言:javascript
运行
复制
const playwright = require('playwright');
const cookiePath = '/home/ubuntu/.config/chromium/Default';
browser['chromium'] = await playwright['chromium'].launchPersistentContext(cookiePath,{
  headless: false,
  args: [
      `--disable-extensions-except=${pathToExtension}`,
      `--load-extension=${pathToExtension}`,
      ],
});
const page = await browser['chromium'].newPage();
const login_url = "https://accounts.google.com/signin/v2/identifier?hl=ja&flowName=GlifWebSignIn&flowEntry=ServiceLogin"; 
await page.goto(login_url);
await page.fill('#identifierId',userinfo['id']);
await page.click("#identifierNext");
await page.fill('[name=password]',userinfo['password']);
await page.click("#passwordNext");
EN

回答 2

Stack Overflow用户

发布于 2021-08-15 12:35:56

这对我来说很有效:

代码语言:javascript
运行
复制
const browser = await playwright.chromium.launch({
  ignoreDefaultArgs: ['--disable-component-extensions-with-background-pages']
})
票数 1
EN

Stack Overflow用户

发布于 2021-06-18 14:30:04

我的解决方案是:

代码语言:javascript
运行
复制
const { chromium } = require("playwright");

(async () => {
    const browser = await chromium.launch({
        headless: false,
        args: ["--disable-dev-shm-usage"],
    });
    const context = await browser.newContext({});
    const page = await context.newPage();
    const navigationPromise = page.waitForNavigation({
        waitUntil: "domcontentloaded",
    });
    await page.setDefaultNavigationTimeout(0);
    await page.goto(
        "https://accounts.google.com/signin/v2/identifier?hl=en&flowName=GlifWebSignIn&flowEntry=ServiceLogin"
    );
    await navigationPromise;
    await page.waitForSelector('input[type="email"]');
    await page.type('input[type="email"]', "youremail");
    await page.click("#identifierNext");
    await page.waitForSelector('input[type="password"]', { visible: true });
    await page.type('input[type="password"]', "yourpassword");
    await page.waitForSelector("#passwordNext", { visible: true });
    await page.click("#passwordNext");
    await navigationPromise;
    //you are in

我想你也可以用木偶搜索登录到谷歌。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65139098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档