aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
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