summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorEmilien Devos <contact@emiliendevos.be>2020-05-22 19:58:48 +0200
committerEmilien Devos <contact@emiliendevos.be>2020-05-22 19:58:48 +0200
commite91177fc59d8862f87010ff30d1986d2a37a0b58 (patch)
treeb5d9880ccae0ab2704fb3ff15686b79befc1c7ad /index.js
working version
Diffstat (limited to 'index.js')
-rw-r--r--index.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..90658f0
--- /dev/null
+++ b/index.js
@@ -0,0 +1,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("cloudflare"))
+ await page.waitForNavigation();
+ ctx.body = await page.content();
+ await page.close();
+ }
+ else {
+ ctx.body = "Please specify the URL query string.";
+ }
+ });
+ app.listen(3000);
+})(); \ No newline at end of file