Update index.js
Browse files
index.js
CHANGED
|
@@ -85,6 +85,53 @@ app.get('/proxy', async (req, res) => {
|
|
| 85 |
}
|
| 86 |
});
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
app.all('/imagetopdf', async (req, res) => {
|
| 89 |
if (!['POST'].includes(req.method)) return res.status(405).json({ success: false, message: 'Method Not Allowed' })
|
| 90 |
|
|
@@ -291,19 +338,32 @@ app.get('/dongo', async (req, res) => {
|
|
| 291 |
});
|
| 292 |
|
| 293 |
app.get('/fetch-page', async (req, res) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
const browser = await playwright.chromium.launch({
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
|
|
|
| 299 |
const context = await browser.newContext({
|
| 300 |
extraHTTPHeaders: {
|
| 301 |
'accept': '*/*',
|
| 302 |
'accept-language': 'en-US,en;q=0.9,id;q=0.8',
|
| 303 |
'cache-control': 'no-cache',
|
| 304 |
-
'origin':
|
| 305 |
'pragma': 'no-cache',
|
| 306 |
-
'referer':
|
| 307 |
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
|
| 308 |
'sec-ch-ua-mobile': '?0',
|
| 309 |
'sec-ch-ua-platform': '"Windows"',
|
|
@@ -314,14 +374,33 @@ app.get('/fetch-page', async (req, res) => {
|
|
| 314 |
}
|
| 315 |
});
|
| 316 |
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
});
|
| 326 |
|
| 327 |
const PORT = process.env.PORT || 7860
|
|
|
|
| 85 |
}
|
| 86 |
});
|
| 87 |
|
| 88 |
+
app.get('/pages', async (req, res) => {
|
| 89 |
+
const targetUrl = req.query.url;
|
| 90 |
+
|
| 91 |
+
if (!targetUrl) {
|
| 92 |
+
return res.status(400).json({ error: 'Parameter "url" dibutuhkan' });
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
const browser = await playwright.chromium.launch({
|
| 96 |
+
headless: true,
|
| 97 |
+
executablePath: '/usr/bin/chromium', // pastikan path ini benar di server kamu
|
| 98 |
+
args: ['--no-sandbox']
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
const context = await browser.newContext({
|
| 102 |
+
extraHTTPHeaders: {
|
| 103 |
+
'accept': '*/*',
|
| 104 |
+
'accept-language': 'en-US,en;q=0.9,id;q=0.8',
|
| 105 |
+
'cache-control': 'no-cache',
|
| 106 |
+
'origin': 'https://doujindesu.tv',
|
| 107 |
+
'pragma': 'no-cache',
|
| 108 |
+
'referer': 'https://doujindesu.tv',
|
| 109 |
+
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
|
| 110 |
+
'sec-ch-ua-mobile': '?0',
|
| 111 |
+
'sec-ch-ua-platform': '"Windows"',
|
| 112 |
+
'sec-fetch-dest': 'script',
|
| 113 |
+
'sec-fetch-mode': 'cors',
|
| 114 |
+
'sec-fetch-site': 'cross-site',
|
| 115 |
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
|
| 116 |
+
}
|
| 117 |
+
});
|
| 118 |
+
|
| 119 |
+
try {
|
| 120 |
+
const page = await context.newPage();
|
| 121 |
+
await page.goto(targetUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
| 122 |
+
|
| 123 |
+
// Tunggu ekstra jika perlu ngelewatin challenge
|
| 124 |
+
await page.waitForTimeout(8000);
|
| 125 |
+
|
| 126 |
+
const content = await page.content();
|
| 127 |
+
res.send(content);
|
| 128 |
+
} catch (err) {
|
| 129 |
+
res.status(500).json({ error: 'Gagal fetch halaman', detail: err.message });
|
| 130 |
+
} finally {
|
| 131 |
+
await browser.close();
|
| 132 |
+
}
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
app.all('/imagetopdf', async (req, res) => {
|
| 136 |
if (!['POST'].includes(req.method)) return res.status(405).json({ success: false, message: 'Method Not Allowed' })
|
| 137 |
|
|
|
|
| 338 |
});
|
| 339 |
|
| 340 |
app.get('/fetch-page', async (req, res) => {
|
| 341 |
+
const targetUrl = req.query.url;
|
| 342 |
+
|
| 343 |
+
if (!targetUrl) {
|
| 344 |
+
return res.status(400).json({
|
| 345 |
+
developer: "KyoukaDev",
|
| 346 |
+
status: false,
|
| 347 |
+
message: 'Parameter "url" dibutuhkan',
|
| 348 |
+
});
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
const baseUrl = new URL(targetUrl).origin;
|
| 352 |
+
|
| 353 |
const browser = await playwright.chromium.launch({
|
| 354 |
+
headless: true,
|
| 355 |
+
executablePath: '/usr/bin/chromium', // pastikan path ini valid
|
| 356 |
+
args: ['--no-sandbox']
|
| 357 |
+
});
|
| 358 |
+
|
| 359 |
const context = await browser.newContext({
|
| 360 |
extraHTTPHeaders: {
|
| 361 |
'accept': '*/*',
|
| 362 |
'accept-language': 'en-US,en;q=0.9,id;q=0.8',
|
| 363 |
'cache-control': 'no-cache',
|
| 364 |
+
'origin': baseUrl,
|
| 365 |
'pragma': 'no-cache',
|
| 366 |
+
'referer': baseUrl,
|
| 367 |
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
|
| 368 |
'sec-ch-ua-mobile': '?0',
|
| 369 |
'sec-ch-ua-platform': '"Windows"',
|
|
|
|
| 374 |
}
|
| 375 |
});
|
| 376 |
|
| 377 |
+
try {
|
| 378 |
+
const page = await context.newPage();
|
| 379 |
+
await page.goto(targetUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
|
| 380 |
+
await page.waitForTimeout(8000);
|
| 381 |
+
|
| 382 |
+
const content = await page.content();
|
| 383 |
+
|
| 384 |
+
res.json({
|
| 385 |
+
developer: "KyoukaDev",
|
| 386 |
+
status: true,
|
| 387 |
+
data: {
|
| 388 |
+
results: [
|
| 389 |
+
{ content }
|
| 390 |
+
]
|
| 391 |
+
}
|
| 392 |
+
});
|
| 393 |
|
| 394 |
+
} catch (err) {
|
| 395 |
+
res.status(500).json({
|
| 396 |
+
developer: "KyoukaDev",
|
| 397 |
+
status: false,
|
| 398 |
+
message: 'Gagal fetch halaman',
|
| 399 |
+
error: err.message
|
| 400 |
+
});
|
| 401 |
+
} finally {
|
| 402 |
+
await browser.close();
|
| 403 |
+
}
|
| 404 |
});
|
| 405 |
|
| 406 |
const PORT = process.env.PORT || 7860
|