mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
fix(route): add full-text output for yystv (#16593)
* fix(route): add full-text output for yystv * fix: cheerio issue * fix: type
This commit is contained in:
+28
-19
@@ -1,7 +1,8 @@
|
||||
import { Route } from '@/types';
|
||||
import got from '@/utils/got';
|
||||
import type { Route, DataItem } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
import { parseRelativeDate } from '@/utils/parse-date';
|
||||
import cache from '@/utils/cache';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/docs',
|
||||
@@ -22,34 +23,42 @@ export const route: Route = {
|
||||
},
|
||||
],
|
||||
name: '游研社 - 全部文章',
|
||||
maintainers: ['HaitianLiu'],
|
||||
maintainers: ['HaitianLiu', 'yy4382'],
|
||||
handler,
|
||||
url: 'yystv.cn/docs',
|
||||
};
|
||||
|
||||
async function handler() {
|
||||
const url = `https://www.yystv.cn/docs`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
});
|
||||
const response = await ofetch(url);
|
||||
|
||||
const data = response.data;
|
||||
const $ = load(data);
|
||||
const $ = load(response);
|
||||
|
||||
const items = $('.list-container li')
|
||||
.slice(0, 18)
|
||||
.map(function () {
|
||||
const itemList = $('.list-container li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
const itemElement = $(item);
|
||||
const info = {
|
||||
title: $('.list-article-title', this).text(),
|
||||
link: 'https://www.yystv.cn' + $('a', this).attr('href'),
|
||||
pubDate: parseRelativeDate($('.c-999', this).text()),
|
||||
author: $('.handler-author-link', this).text(),
|
||||
description: $('.list-article-intro', this).text(),
|
||||
title: itemElement.find('.list-article-title').text(),
|
||||
link: 'https://www.yystv.cn' + itemElement.find('a').attr('href'),
|
||||
pubDate: parseRelativeDate(itemElement.find('.c-999').text()),
|
||||
author: itemElement.find('.handler-author-link').text(),
|
||||
description: itemElement.find('.list-article-intro').text(),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
}) satisfies DataItem[];
|
||||
|
||||
const items = (await Promise.all(
|
||||
itemList.map(
|
||||
(item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const resp = await ofetch(item.link);
|
||||
const $ = load(resp);
|
||||
item.description = $('#main section.article-section .doc-content > div').html() || item.description;
|
||||
return item;
|
||||
}) as Promise<DataItem>
|
||||
)
|
||||
)) satisfies DataItem[];
|
||||
|
||||
return {
|
||||
title: '游研社-' + $('title').text(),
|
||||
|
||||
Reference in New Issue
Block a user