|
const app = require("express")(); |
|
|
|
const chromium = require('chrome-aws-lambda'); |
|
const puppeteer = require('puppeteer-core'); |
|
|
|
app.get("/", (req, res) => { |
|
res.send('Hello AuthCode') |
|
}) |
|
|
|
app.get("/api", async (req, res) => { |
|
const browser = await puppeteer.launch({ |
|
args: chromium.args, |
|
executablePath: process.env.CHROME_EXECUTABLE_PATH || await chromium.executablePath, |
|
headless: true, |
|
}); |
|
|
|
const page = await browser.newPage(); |
|
|
|
await page.goto("https://liaobots.work/"); |
|
await page.click('label.button'); |
|
await page.waitForNavigation(); |
|
await page.waitForTimeout(2000); |
|
|
|
|
|
const value = await page.evaluate(() => { |
|
|
|
return localStorage.getItem('authCode'); |
|
}); |
|
|
|
|
|
await browser.close(); |
|
|
|
res.send(value); |
|
|
|
}); |
|
|
|
app.listen(process.env.PORT || 3000, () => { |
|
console.log("Server started"); |
|
}); |
|
|
|
module.exports = app; |