我无法使用 page.goto() 从一个页面转到另一个页面 - Puppeteer

I can't go from a page to another using page.goto() - Puppeteer

我正在尝试制作一个 InstagramBot 登录然后转到某个配置文件,我的代码昨天工作了一段时间,然后就停止工作了。

我尝试从 github 克隆我的存储库,但它也不起作用,有时它再次起作用,但如果我尝试创建另一个函数,代码将忽略更改页面的代码。

我也试过创建一个新页面,然后在这个新页面中使用 goto 功能,它起作用了,但是帐户没有保持登录状态

我使用的puppeteer版本:1.16.0

我使用的 node.js 版本:v10.15.3


const puppeteer = require('puppeteer');

const BASE_URL = "https://www.instagram.com/accounts/login/?hl=en&source=auth_switcher";
const instagram = {
  browser: null,
  page: null,
  profile_url: null,
    initialize: async (profile) => {
    instagram.browser = await puppeteer.launch({
      headless: false
    })

    instagram.profile_url = await "https://www.instagram.com/" + profile;
    instagram.page = await instagram.browser.newPage();
    await instagram.page.goto(BASE_URL, {waitUntil: 'networkidle2'});

  },

  login: async(username, password) =>{
    await instagram.page.waitFor(1000);
    await instagram.page.type('input[name="username"]', username);
    await instagram.page.type('input[name="password"', password);
    await instagram.page.click('button[type="submit"]');
    await instagram.page.waitFor(1500);
    await console.log(instagram.profile_url);
    await instagram.page.goto(instagram.profile_url, {timeout: 0, waitUntil: 'domcontentloaded'}); // the code just ignore this line
    await instagram.page.waitFor(1000);
  },
  getPhotosLinks: async() => {
    console.log("Do something here");
  }

}
module.exports = instagram;

它没有给出任何错误信息,只是不起作用

替换

await instagram.page.click('button[type="submit"]');
await instagram.page.waitFor(1500);

await Promise.all([
      instagram.page.click('button[type="submit"]');,
      instagram.page.waitForNavigation()
    ]);

看看它是否有效