run browser headed to support checks requiring you to click something
This commit is contained in:
parent
d3325eccb4
commit
49beedc24d
9
index.js
9
index.js
|
@ -5,18 +5,19 @@ if (process.argv.length !== 3) {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
const browser = await firefox.launch();
|
||||
const browser = await firefox.launch({ headless: false });
|
||||
browser.on('disconnected', () => process.exit(1));
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
page.on('close', () => process.exit(1));
|
||||
const user_agent = await page.evaluate('navigator.userAgent');
|
||||
|
||||
await page.goto(`https://${process.argv[2]}`);
|
||||
|
||||
let cf_clearance;
|
||||
for (let i = 0; i < 100 && !cf_clearance; i++) {
|
||||
while (!cf_clearance) {
|
||||
await new Promise(res => setTimeout(res, 100));
|
||||
cf_clearance = (await context.cookies()).find(({ name }) => name === 'cf_clearance');
|
||||
}
|
||||
console.log(JSON.stringify({ headers: { cookie: `cf_clearance=${cf_clearance.value}`, 'user-agent': user_agent } }));
|
||||
|
||||
await browser.close();
|
||||
process.exit(0);
|
||||
|
|
Loading…
Reference in New Issue