initial commit
This commit is contained in:
commit
3cb9d6f0e8
4 changed files with 23 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/node_modules/
|
2
docker.sh
Executable file
2
docker.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
docker run --rm --volume "$PWD":/app mcr.microsoft.com/playwright:v1.22.2 node /app $1
|
14
index.js
Normal file
14
index.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { firefox } from 'playwright';
|
||||
|
||||
const browser = await firefox.launch();
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
await page.goto(`https://${process.argv[2]}`);
|
||||
await new Promise(res => setTimeout(res, 5000));
|
||||
|
||||
const cf_clearance = (await context.cookies()).find(({ name }) => name === 'cf_clearance').value;
|
||||
const user_agent = await page.evaluate('navigator.userAgent');
|
||||
console.log(JSON.stringify({ headers: { cookie: `cf_clearance=${cf_clearance}`, 'user-agent': user_agent } }));
|
||||
|
||||
await browser.close();
|
6
package.json
Normal file
6
package.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"playwright": "1.22.2"
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue