Update index.js
Browse files
index.js
CHANGED
|
@@ -3,7 +3,9 @@ const cors = require('cors');
|
|
| 3 |
const { connect } = require("puppeteer-real-browser");
|
| 4 |
const puppeteer = require('puppeteer-extra');
|
| 5 |
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
|
|
| 6 |
puppeteer.use(StealthPlugin());
|
|
|
|
| 7 |
const recaptchav3 = require('./endpoints/recaptchav3');
|
| 8 |
const app = express();
|
| 9 |
const port = process.env.PORT || 7860;
|
|
@@ -54,6 +56,21 @@ async function createBrowser() {
|
|
| 54 |
});
|
| 55 |
|
| 56 |
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
return { browser, page };
|
| 59 |
}
|
|
@@ -77,7 +94,7 @@ app.post('/recaptchav3', async (req, res) => {
|
|
| 77 |
browserInstance = browser;
|
| 78 |
|
| 79 |
const token = await recaptchav3(page, url, siteKey, action || 'submit');
|
| 80 |
-
|
| 81 |
res.json({
|
| 82 |
status: "success",
|
| 83 |
token: token
|
|
|
|
| 3 |
const { connect } = require("puppeteer-real-browser");
|
| 4 |
const puppeteer = require('puppeteer-extra');
|
| 5 |
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
| 6 |
+
|
| 7 |
puppeteer.use(StealthPlugin());
|
| 8 |
+
|
| 9 |
const recaptchav3 = require('./endpoints/recaptchav3');
|
| 10 |
const app = express();
|
| 11 |
const port = process.env.PORT || 7860;
|
|
|
|
| 56 |
});
|
| 57 |
|
| 58 |
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
|
| 59 |
+
|
| 60 |
+
const cookies = [
|
| 61 |
+
{
|
| 62 |
+
name: 'NID',
|
| 63 |
+
value: '511=your_cookie_value_here',
|
| 64 |
+
domain: '.google.com',
|
| 65 |
+
path: '/',
|
| 66 |
+
expires: Date.now() + 1000 * 60 * 60 * 24 * 365,
|
| 67 |
+
httpOnly: true,
|
| 68 |
+
secure: true,
|
| 69 |
+
sameSite: 'None'
|
| 70 |
+
}
|
| 71 |
+
];
|
| 72 |
+
|
| 73 |
+
await page.setCookie(...cookies);
|
| 74 |
|
| 75 |
return { browser, page };
|
| 76 |
}
|
|
|
|
| 94 |
browserInstance = browser;
|
| 95 |
|
| 96 |
const token = await recaptchav3(page, url, siteKey, action || 'submit');
|
| 97 |
+
|
| 98 |
res.json({
|
| 99 |
status: "success",
|
| 100 |
token: token
|