Delete test.js
Browse files
test.js
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
const app = require("express")();
|
2 |
-
|
3 |
-
let chrome = {};
|
4 |
-
let puppeteer;
|
5 |
-
|
6 |
-
if (process.env.AWS_LAMBDA_FUNCTION_VERSION) {
|
7 |
-
chrome = require("chrome-aws-lambda");
|
8 |
-
puppeteer = require("puppeteer-core");
|
9 |
-
} else {
|
10 |
-
puppeteer = require("puppeteer");
|
11 |
-
}
|
12 |
-
|
13 |
-
app.get("/api", async (req, res) => {
|
14 |
-
let options = {};
|
15 |
-
|
16 |
-
if (process.env.AWS_LAMBDA_FUNCTION_VERSION) {
|
17 |
-
options = {
|
18 |
-
args: [...chrome.args, "--hide-scrollbars", "--disable-web-security"],
|
19 |
-
defaultViewport: chrome.defaultViewport,
|
20 |
-
executablePath: await chrome.executablePath,
|
21 |
-
headless: true,
|
22 |
-
ignoreHTTPSErrors: true,
|
23 |
-
};
|
24 |
-
}
|
25 |
-
|
26 |
-
try {
|
27 |
-
let browser = await puppeteer.launch(options);
|
28 |
-
|
29 |
-
let page = await browser.newPage();
|
30 |
-
await page.goto("https://liaobots.work/");
|
31 |
-
await page.click('label.button');
|
32 |
-
await page.waitForNavigation();
|
33 |
-
await page.waitForTimeout(2000);
|
34 |
-
|
35 |
-
// Execute JavaScript code in the context of the page
|
36 |
-
const value = await page.evaluate(() => {
|
37 |
-
// Retrieve the value from localStorage
|
38 |
-
return localStorage.getItem('authCode');
|
39 |
-
});
|
40 |
-
|
41 |
-
res.send(value);
|
42 |
-
} catch (err) {
|
43 |
-
console.error(err);
|
44 |
-
return null;
|
45 |
-
}
|
46 |
-
});
|
47 |
-
|
48 |
-
app.listen(process.env.PORT || 3000, () => {
|
49 |
-
console.log("Server started");
|
50 |
-
});
|
51 |
-
|
52 |
-
module.exports = app;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|