Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
@@ -147,24 +147,15 @@ app.all('/animelast', async (req, res) => {
|
|
147 |
});
|
148 |
});
|
149 |
|
150 |
-
async
|
151 |
-
const
|
152 |
-
|
153 |
-
|
154 |
-
const title = await page.title();
|
155 |
-
await browser.close();
|
156 |
-
return title;
|
157 |
-
}
|
158 |
-
|
159 |
-
app.get('/scrape-title', async (req, res) => {
|
160 |
-
const url = req.query.url;
|
161 |
-
if (!url) {
|
162 |
-
return res.status(400).send('URL is required');
|
163 |
}
|
164 |
|
165 |
try {
|
166 |
-
const
|
167 |
-
res.send({
|
168 |
} catch (error) {
|
169 |
res.status(500).send('An error occurred while scraping the title');
|
170 |
}
|
@@ -327,4 +318,37 @@ async function enhanceImage(url) {
|
|
327 |
|
328 |
await browser.close()
|
329 |
return json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
}
|
|
|
147 |
});
|
148 |
});
|
149 |
|
150 |
+
app.get('/doujins', async (req, res) => {
|
151 |
+
const q = req.query.q;
|
152 |
+
if (!q) {
|
153 |
+
return res.status(400).send('q is required');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
}
|
155 |
|
156 |
try {
|
157 |
+
const result = await DouDesusearch(q);
|
158 |
+
res.send({ result });
|
159 |
} catch (error) {
|
160 |
res.status(500).send('An error occurred while scraping the title');
|
161 |
}
|
|
|
318 |
|
319 |
await browser.close()
|
320 |
return json
|
321 |
+
}
|
322 |
+
|
323 |
+
async function DouDesusearch(q) {
|
324 |
+
const url = 'https://doujindesu.tv/?s=' + q
|
325 |
+
const browser = await chromium.launch();
|
326 |
+
const context = await browser.newContext({
|
327 |
+
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
328 |
+
});
|
329 |
+
const page = await context.newPage();
|
330 |
+
await page.goto(url);
|
331 |
+
await page.waitForLoadState('load');
|
332 |
+
|
333 |
+
const baseUrl = 'https://doujindesu.tv';
|
334 |
+
const entries = await page.$$eval('.entries .entry', (articles, baseUrl) => {
|
335 |
+
return articles.map(article => {
|
336 |
+
let dataTags = article.getAttribute('data-tags');
|
337 |
+
if (dataTags) {
|
338 |
+
dataTags = dataTags.replace(/\|/g, ',');
|
339 |
+
}
|
340 |
+
const href = article.querySelector('a')?.getAttribute('href');
|
341 |
+
const title = article.querySelector('a')?.getAttribute('title');
|
342 |
+
const imgSrc = article.querySelector('.thumbnail img')?.getAttribute('src');
|
343 |
+
return {
|
344 |
+
Tags: dataTags,
|
345 |
+
Url: href ? baseUrl + href : null,
|
346 |
+
Title: title,
|
347 |
+
ThumbnailUrl: imgSrc
|
348 |
+
};
|
349 |
+
});
|
350 |
+
}, baseUrl);
|
351 |
+
|
352 |
+
await browser.close();
|
353 |
+
return entries;
|
354 |
}
|