xvideosx 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/api/videos/index.js
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
/* eslint-disable no-undef */
|
3
|
+
const puppeteer = require('puppeteer');
|
4
|
+
|
5
|
+
const newFresh = async ({ url, puppeteerConfig } = {}) => {
|
6
|
+
let browser;
|
7
|
+
try {
|
8
|
+
browser = await puppeteer.launch(puppeteerConfig);
|
9
|
+
const page = await browser.newPage();
|
10
|
+
await page.goto(url, { waitUntil: 'networkidle2' });
|
11
|
+
|
12
|
+
const result = await page.evaluate(() => {
|
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,
|
31
|
+
});
|
32
|
+
}
|
33
|
+
return result;
|
34
|
+
});
|
35
|
+
return data;
|
36
|
+
});
|
37
|
+
} finally {
|
38
|
+
if (browser) await browser.close();
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
module.exports = newFresh;
|
File without changes
|
package/lib/xvideos.spec.js
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
/* eslint-disable padded-blocks */
|
2
|
-
|
3
1
|
const chai = require('chai');
|
4
2
|
const xvideos = require('.');
|
5
3
|
|
@@ -8,7 +6,6 @@ before(() => {
|
|
8
6
|
});
|
9
7
|
|
10
8
|
describe('xvideos', () => {
|
11
|
-
|
12
9
|
it('should have xvideos api functions', async () => {
|
13
10
|
xvideos.should.be.an('object');
|
14
11
|
xvideos.videos.should.be.an('object');
|
@@ -17,6 +14,6 @@ describe('xvideos', () => {
|
|
17
14
|
xvideos.videos.best.should.be.a('function');
|
18
15
|
xvideos.videos.verified.should.be.a('function');
|
19
16
|
xvideos.videos.details.should.be.a('function');
|
17
|
+
xvideos.videos.newFresh.should.be.a('function');
|
20
18
|
}).timeout(10000);
|
21
|
-
|
22
19
|
});
|