blob: bc19d1a3c88441c42065f72b88229d4c67303862 (
plain)
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
|
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin());
const Koa = require('koa');
const app = new Koa();
(async () => {
const browser = await puppeteer.launch({
headless: true,
executablePath: '/usr/bin/chromium-browser',
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
app.use(async ctx => {
if (ctx.query.url) {
const page = await browser.newPage();
await page.goto(ctx.query.url);
if ((await page.content()).includes("cf-browser-verification"))
await page.waitForNavigation();
ctx.body = await page.content();
await page.close();
}
else {
ctx.body = "Please specify the URL query string.";
}
});
app.listen(3000);
})();
|