puppeteer

puppeteer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
async login () {
const loginUrl = `https://www.facebook.com/login/?next=https%3A%2F%2Fwww.facebook.com%2Fpriceship%2F`;
const username = config.facebook.id;
const password = config.facebook.pw;

const page = await this.browser.newPage();
await page.goto(loginUrl);

const USERNAME_SELECTOR = '#email';
const PASSWORD_SELECTOR = '#pass';
const BUTTON_SELECTOR = '#loginbutton';

await page.click(USERNAME_SELECTOR);
await page.keyboard.type(username);

await page.click(PASSWORD_SELECTOR);
await page.keyboard.type(password);

await page.click(BUTTON_SELECTOR);
await page.waitForNavigation();
const cookies = await page.cookies();
console.log('cookies',cookies)
}

References