xvideosx 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
package/README.md
CHANGED
@@ -18,6 +18,27 @@ const details = async ({ url, puppeteerConfig } = {}) => {
|
|
18
18
|
const videoWidth = $('meta[property="og:video:width"]').attr('content');
|
19
19
|
const videoHeight = $('meta[property="og:video:height"]').attr('content');
|
20
20
|
const views = $('#nb-views-number').text();
|
21
|
+
const relatedContentItems = $('div[class=mozaique]').html();
|
22
|
+
const newData = cheerio.load(relatedContentItems);
|
23
|
+
const varios = newData('.thumb-block');
|
24
|
+
const videos = varios.map((index, element) => {
|
25
|
+
const $element = newData(element);
|
26
|
+
|
27
|
+
const title = $element.find('.title a').text();
|
28
|
+
const duration = $element.find('.duration').text();
|
29
|
+
const channel = $element.find('.metadata .name').text();
|
30
|
+
const url = 'https://www.xvideos.com' + $element.find('.title a').attr('href');
|
31
|
+
const thumbNail = $element.find('.thumb img').attr('src');
|
32
|
+
return {
|
33
|
+
title,
|
34
|
+
duration,
|
35
|
+
channel,
|
36
|
+
thumbNail,
|
37
|
+
url,
|
38
|
+
},
|
39
|
+
}).get()
|
40
|
+
|
41
|
+
|
21
42
|
const videoScript = $('#video-player-bg > script:nth-child(6)').html();
|
22
43
|
const files = {
|
23
44
|
low: (videoScript.match('html5player.setVideoUrlLow\\(\'(.*?)\'\\);') || [])[1],
|
@@ -39,6 +60,7 @@ const details = async ({ url, puppeteerConfig } = {}) => {
|
|
39
60
|
videoWidth,
|
40
61
|
videoHeight,
|
41
62
|
files,
|
63
|
+
videos
|
42
64
|
};
|
43
65
|
} finally {
|
44
66
|
if (browser) await browser.close();
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/* eslint-disable linebreak-style */
|
2
2
|
/* eslint-disable no-undef */
|
3
3
|
const puppeteer = require('puppeteer');
|
4
|
+
const cheerio = require('cheerio');
|
4
5
|
|
5
6
|
const newFresh = async ({ url, puppeteerConfig } = {}) => {
|
6
7
|
let browser;
|
@@ -8,33 +9,29 @@ const newFresh = async ({ url, puppeteerConfig } = {}) => {
|
|
8
9
|
browser = await puppeteer.launch(puppeteerConfig);
|
9
10
|
const page = await browser.newPage();
|
10
11
|
await page.goto(url, { waitUntil: 'networkidle2' });
|
12
|
+
const html = await page.content();
|
13
|
+
const $ = cheerio.load(html);
|
14
|
+
const data = $('div[class=mozaique]').html()
|
15
|
+
const $getVideos = cheerio.load(data);
|
16
|
+
const mozaique = $getVideos('.thumb-block');
|
17
|
+
const videos = mozaique.map((index, element) => {
|
18
|
+
const $element = $getVideos(element);
|
19
|
+
const title = $element.find('.title a').attr('title');
|
20
|
+
const url = "https://www.xvideos.com" + $element.find('.title a').attr('href');
|
21
|
+
const thumbNail = $element.find('.thumb img').attr('src');
|
22
|
+
const duration = $element.find('.duration').text();
|
23
|
+
const name = $element.find('.metadata .name').text();
|
11
24
|
|
12
|
-
|
13
|
-
const thumbs = document.querySelectorAll('.thumb');
|
14
|
-
const titles = document.querySelectorAll('.title');
|
15
|
-
const data = [];
|
16
|
-
thumbs.forEach((thumb, index) => {
|
17
|
-
const anchor = thumb.querySelector('a');
|
18
|
-
const img = thumb.querySelector('img');
|
19
|
-
const text = titles[index];
|
20
|
-
const url = anchor ? anchor.href : null;
|
21
|
-
let title;
|
22
|
-
if (text) {
|
23
|
-
title = text.textContent;
|
24
|
-
}
|
25
|
-
if (img) {
|
26
|
-
const thumb = img.src;
|
27
|
-
data.push({
|
28
|
-
thumb,
|
29
|
-
title,
|
30
|
-
url,
|
25
|
+
return {
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
title,
|
28
|
+
url,
|
29
|
+
imgSrc: thumbNail,
|
30
|
+
duration,
|
31
|
+
name,
|
32
|
+
},
|
33
|
+
}).get();
|
34
|
+
return videos;
|
38
35
|
} finally {
|
39
36
|
if (browser) await browser.close();
|
40
37
|
}
|