-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
45 lines (39 loc) · 949 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const puppeteer = require('puppeteer');
const CRED = require('./creds');
const sleep = async (ms) => {
return new Promise((res, rej) => {
setTimeout(() => {
res();
}, ms)
});
}
const ID = {
login: '#email',
pass: '#pass'
};
(async () => {
const browser = await puppeteer.launch({
headless: false,
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
let login = async () => {
// login
await page.goto('https://facebook.com', {
waitUntil: 'networkidle2'
});
await page.waitForSelector(ID.login);
console.log(CRED.user);
console.log(ID.login);
await page.type(ID.login, CRED.user);
await page.type(ID.pass, CRED.pass);
await sleep(500);
await page.click("#loginbutton")
console.log("login done");
await page.waitForNavigation();
}
await login();
await page.screenshot({
path: 'facebook.png'
});
})();