mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 19:50:01 +08:00
feat: load pics of searched items
This commit is contained in:
@@ -2,7 +2,7 @@ const { processFeed } = require('./utils');
|
|||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const url = ctx.params.type ? `https://ja.porn-images-xxx.com/search/${ctx.params.type}/${encodeURIComponent(ctx.params.name)}/` : 'https://ja.porn-images-xxx.com/search/';
|
const url = ctx.params.type ? `https://ja.porn-images-xxx.com/search/${ctx.params.type}/${encodeURIComponent(ctx.params.name)}/` : 'https://ja.porn-images-xxx.com/search/';
|
||||||
const items = await processFeed(url);
|
const items = await processFeed(ctx, url);
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: `${ctx.params.name || '新着画像一覧'} - エロ画像`,
|
title: `${ctx.params.name || '新着画像一覧'} - エロ画像`,
|
||||||
link: url,
|
link: url,
|
||||||
|
|||||||
@@ -1,26 +1,46 @@
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
exports.processFeed = async function processFeed(link) {
|
const host = 'https://ja.porn-images-xxx.com/';
|
||||||
|
|
||||||
|
exports.processFeed = async function processFeed(ctx, link) {
|
||||||
const response = await got.get(link);
|
const response = await got.get(link);
|
||||||
const $ = cheerio.load(response.body);
|
const $ = cheerio.load(response.body);
|
||||||
const list = $('ul#image-list li');
|
const list = $('ul#image-list li')
|
||||||
|
.map(function (index, item) {
|
||||||
return (
|
|
||||||
list &&
|
|
||||||
list
|
|
||||||
.map((index, item) => {
|
|
||||||
item = $(item);
|
item = $(item);
|
||||||
return {
|
return {
|
||||||
title: item.find('.image-list-item-title').text(),
|
title: item.find('.image-list-item-title').text(),
|
||||||
link: item.find('.image-list-item-title > a').attr('href'),
|
link: item.find('.image-list-item-title > a').attr('href'),
|
||||||
description: item
|
date: item.find('.image-list-item-regist-date > span').text(),
|
||||||
.find('.image-list-item-image')
|
|
||||||
.html()
|
|
||||||
.replace(/\/p=\d+x\d+/, ''),
|
|
||||||
pubDate: new Date(item.find('.image-list-item-regist-date').text()),
|
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.get()
|
.get();
|
||||||
|
return await Promise.all(
|
||||||
|
list.map(async (info) => {
|
||||||
|
const title = info.title.trim();
|
||||||
|
const date = info.date;
|
||||||
|
const itemUrl = host + info.link;
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await got.get(itemUrl);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const images = $('.icon-overlay > a > img');
|
||||||
|
const desc = cheerio.html(images);
|
||||||
|
const item = {
|
||||||
|
title: title,
|
||||||
|
link: itemUrl,
|
||||||
|
description: desc,
|
||||||
|
pubDate: new Date(date).toUTCString(),
|
||||||
|
};
|
||||||
|
if (desc) {
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(item));
|
||||||
|
}
|
||||||
|
return Promise.resolve(item);
|
||||||
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user