NekonekoID commited on
Commit
c1c8c21
·
verified ·
1 Parent(s): f60d06f

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +23 -25
index.js CHANGED
@@ -243,41 +243,39 @@ function toPDF(urls) {
243
  }
244
 
245
  async function scrapeAnimeInfo() {
 
246
  const browser = await playwright.chromium.launch({
247
- headless: true,
248
- executablePath: '/usr/bin/chromium',
249
- args: ['--no-sandbox']
250
- })
251
-
252
  const page = await browser.newPage();
253
- const url = 'http://66.29.129.161/';
254
-
255
- await page.goto(url);
256
  const pageContent = await page.content();
257
  console.log(pageContent);
 
 
258
 
259
-
260
- const articlesInfo = await page.$$eval('.postbody .is-anime', articles => {
261
- return articles.map(article => {
262
- const title = article.querySelector('h2').textContent.trim();
263
- const thumbnailUrl = article.querySelector('img').src;
264
- const uploadTime = article.querySelector('span x-ts').textContent.trim();
265
- const episodeUrl = article.querySelector('a').href;
266
-
267
- return {
268
- title,
269
- thumbnailUrl,
270
- uploadTime,
271
- episodeUrl
272
- };
273
- });
274
  });
275
 
276
  await browser.close();
277
-
278
- return articlesInfo;
 
 
 
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,