Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
@@ -243,41 +243,39 @@ function toPDF(urls) {
|
|
243 |
}
|
244 |
|
245 |
async function scrapeAnimeInfo() {
|
|
|
246 |
const browser = await playwright.chromium.launch({
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
const page = await browser.newPage();
|
253 |
-
|
254 |
-
|
255 |
-
await page.goto(url);
|
256 |
const pageContent = await page.content();
|
257 |
console.log(pageContent);
|
|
|
|
|
258 |
|
259 |
-
|
260 |
-
const
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
title,
|
269 |
-
thumbnailUrl,
|
270 |
-
uploadTime,
|
271 |
-
episodeUrl
|
272 |
-
};
|
273 |
-
});
|
274 |
});
|
275 |
|
276 |
await browser.close();
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
279 |
}
|
280 |
|
|
|
281 |
async function enhanceImage(url) {
|
282 |
const browser = await playwright.chromium.launch({
|
283 |
headless: true,
|
|
|
243 |
}
|
244 |
|
245 |
async function scrapeAnimeInfo() {
|
246 |
+
try {
|
247 |
const browser = await playwright.chromium.launch({
|
248 |
+
headless: true,
|
249 |
+
executablePath: '/usr/bin/chromium',
|
250 |
+
args: ['--no-sandbox']
|
251 |
+
});
|
|
|
252 |
const page = await browser.newPage();
|
253 |
+
await page.goto('http://66.29.129.161/?filter=latest&cat=1');
|
|
|
|
|
254 |
const pageContent = await page.content();
|
255 |
console.log(pageContent);
|
256 |
+
// Wait for the list of videos to load
|
257 |
+
await page.waitForSelector('.videos-list');
|
258 |
|
259 |
+
// Extract data from all articles
|
260 |
+
const videoData = await page.$$eval('.videos-list article', articles => {
|
261 |
+
return articles.map(article => {
|
262 |
+
const thumbnail = article.querySelector('.post-thumbnail img').src;
|
263 |
+
const title = article.querySelector('header.entry-header span').textContent;
|
264 |
+
const url = article.querySelector('a').href;
|
265 |
+
const duration = article.querySelector('.duration').textContent.trim();
|
266 |
+
return { thumbnail, title, url, duration };
|
267 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
});
|
269 |
|
270 |
await browser.close();
|
271 |
+
return videoData;
|
272 |
+
} catch (error) {
|
273 |
+
console.error('An error occurred during scraping:', error);
|
274 |
+
return []; // Return an empty array in case of error
|
275 |
+
}
|
276 |
}
|
277 |
|
278 |
+
|
279 |
async function enhanceImage(url) {
|
280 |
const browser = await playwright.chromium.launch({
|
281 |
headless: true,
|