forked from DebaucheryLibrarian/traxxx
Fixed comment field not updated. Refactored Nubiles scraper.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const unprint = require('unprint');
|
||||
|
||||
const http = require('../utils/http');
|
||||
const slugify = require('../utils/slugify');
|
||||
|
||||
// Naughty America network
|
||||
@@ -42,6 +43,40 @@ function scrapeLatest(scenes, channel) {
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchLatest(channel, page = 1) {
|
||||
const { tab } = await http.getBrowserSession('naughtyamerica', { useGlobalBrowser: false, useProxy: true, headless: false });
|
||||
const url = `${channel.url}${channel.parameters?.scenes || ''}?page=${page}`;
|
||||
const res = await tab.goto(url);
|
||||
const status = res.status();
|
||||
|
||||
if (status === 200) {
|
||||
const html = await tab.content();
|
||||
const items = unprint.initAll(html, '.site-list .scene-item, .panel-body');
|
||||
|
||||
const scenes = scrapeLatest(items, channel);
|
||||
|
||||
await tab.close();
|
||||
|
||||
return scenes;
|
||||
}
|
||||
|
||||
await tab.close();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
async function fetchLatest(site, page = 1) {
|
||||
const res = await unprint.get(`${site.url}${site.parameters?.scenes || ''}?page=${page}`, { selectAll: '.site-list .scene-item, .panel-body' });
|
||||
|
||||
if (res.ok) {
|
||||
return scrapeLatest(res.context, site);
|
||||
}
|
||||
|
||||
return res.status;
|
||||
}
|
||||
*/
|
||||
|
||||
function scrapeScene({ query }, { url }) {
|
||||
const release = {};
|
||||
|
||||
@@ -98,6 +133,28 @@ function scrapeScene({ query }, { url }) {
|
||||
return release;
|
||||
}
|
||||
|
||||
async function fetchScene(url, _channel) {
|
||||
const { tab } = await http.getBrowserSession('naughtyamerica', { useGlobalBrowser: false, useProxy: true });
|
||||
const res = await tab.goto(url);
|
||||
|
||||
const status = res.status();
|
||||
|
||||
if (status === 200) {
|
||||
const html = await tab.content();
|
||||
const item = unprint.init(html);
|
||||
|
||||
const scene = scrapeScene(item, { url });
|
||||
|
||||
await tab.close();
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
await tab.close();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
async function scrapeProfile({ query }) {
|
||||
const profile = {};
|
||||
|
||||
@@ -107,16 +164,30 @@ async function scrapeProfile({ query }) {
|
||||
return profile;
|
||||
}
|
||||
|
||||
async function fetchLatest(site, page = 1) {
|
||||
const res = await unprint.get(`${site.url}${site.parameters?.scenes || ''}?page=${page}`, { selectAll: '.site-list .scene-item, .panel-body' });
|
||||
async function fetchProfile({ slug }, { channel }) {
|
||||
const { tab } = await http.getBrowserSession('naughtyamerica', { useGlobalBrowser: false, useProxy: true });
|
||||
const url = `${channel.url}/pornstar/${slug}`;
|
||||
const res = await tab.goto(url);
|
||||
|
||||
if (res.ok) {
|
||||
return scrapeLatest(res.context, site);
|
||||
const status = res.status();
|
||||
|
||||
if (status === 200) {
|
||||
const html = await tab.content();
|
||||
const item = unprint.init(html, '.bio-info, .performer-details');
|
||||
|
||||
const profile = scrapeProfile(item, { url });
|
||||
|
||||
await tab.close();
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
return res.status;
|
||||
await tab.close();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
async function fetchProfile({ slug }, { channel }) {
|
||||
const res = await unprint.get(`${channel.url}/pornstar/${slug}`, { select: '.bio-info, .performer-details' });
|
||||
|
||||
@@ -126,9 +197,10 @@ async function fetchProfile({ slug }, { channel }) {
|
||||
|
||||
return res.status;
|
||||
}
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
fetchLatest,
|
||||
fetchScene,
|
||||
fetchProfile,
|
||||
scrapeScene,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user