mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: huodongxing get fulltext (#3130)
This commit is contained in:
+39
-26
@@ -1,5 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const URL = require('url');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
@@ -10,35 +11,47 @@ module.exports = async (ctx) => {
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const list = $('div.search-tab-content-item');
|
||||
const list = $('div.search-tab-content-item').get();
|
||||
|
||||
const ProcessFeed = async (link) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const content = $('#event_desc_page');
|
||||
|
||||
return content.html();
|
||||
};
|
||||
|
||||
const host = 'https://www.huodongxing.com';
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const $a = $('.item-title');
|
||||
const link = URL.resolve(host, $a.attr('href'));
|
||||
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const single = {
|
||||
title: $a.text(),
|
||||
description: await ProcessFeed(link),
|
||||
link: link,
|
||||
author: $('.user-name').text(),
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '活动行',
|
||||
link: 'https://www.huodongxing.com/eventlist',
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item
|
||||
.find('.item-title')
|
||||
.text()
|
||||
.trim(),
|
||||
link: item.find('.item-title').attr('href'),
|
||||
description:
|
||||
item.find('.item-data').text() +
|
||||
' ' +
|
||||
item
|
||||
.find('.item-dress')
|
||||
.text()
|
||||
.trim(),
|
||||
author: item
|
||||
.find('.user-name')
|
||||
.text()
|
||||
.trim(),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user