Javascript 我能';t使用page.goto()-puppeter从一页转到另一页
我正在尝试制作一个InstagramBot,登录后转到某个配置文件,我的代码昨天工作了一段时间,然后就停止工作了 我曾尝试从github克隆我的存储库,但它也不起作用,有时会再次起作用,但如果我尝试创建另一个函数,代码只会忽略更改页面的代码行 我还尝试创建一个新页面,然后在这个新页面中使用goto函数,它工作正常,但是帐户没有保持登录 我正在使用的木偶演员版本:1.16.0 我正在使用的node.js版本:v10.15.3Javascript 我能';t使用page.goto()-puppeter从一页转到另一页,javascript,node.js,puppeteer,Javascript,Node.js,Puppeteer,我正在尝试制作一个InstagramBot,登录后转到某个配置文件,我的代码昨天工作了一段时间,然后就停止工作了 我曾尝试从github克隆我的存储库,但它也不起作用,有时会再次起作用,但如果我尝试创建另一个函数,代码只会忽略更改页面的代码行 我还尝试创建一个新页面,然后在这个新页面中使用goto函数,它工作正常,但是帐户没有保持登录 我正在使用的木偶演员版本:1.16.0 我正在使用的node.js版本:v10.15.3 const puppeteer = require('puppetee
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);
与
看看它是否管用哦,管用了,谢谢!我需要学习更多关于javascript的知识:)
await Promise.all([
instagram.page.click('button[type="submit"]');,
instagram.page.waitForNavigation()
]);