mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 16:20:27 +08:00
* fix(route):route 8kcosplay: 子路由/category 无法获取
* feat(route):route 8kcosplay: 增加/tag
* 一些修正
* doc:子路由/tag
* style:
* disable pre-commit hook
* fix(route):route 8kcosplay: 最新文章无法获取
* fix(route):route 8kcosplay: 遵循pubDate规范
* style(route):route 8kcosplay: 遵循pubDate规范
* route 8kcosplay: 获取不到页面时不返回item
* Revert "disable pre-commit hook"
This reverts commit d1342b9ea2.
* fix(route):route 8kcosplay: 删除不必要的async
* fix(route):route 8kcosplay: 限制文章全文获取数量
* use @/utils/got
* feat(route):route 8kcosplay: 使用limit query限制文章全文获取数量
* refactor: migrated to v2
Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
25 lines
762 B
JavaScript
25 lines
762 B
JavaScript
const Cheerio = require('cheerio');
|
|
const got = require('@/utils/got');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
async function loadArticle(link) {
|
|
const resp = await got(link);
|
|
const article = Cheerio.load(resp.body);
|
|
const entryChildren = article('div.entry-content').children();
|
|
const imgs = entryChildren
|
|
.find('noscript')
|
|
.toArray()
|
|
.map((e) => e.children[0].data);
|
|
const txt = entryChildren
|
|
.slice(2)
|
|
.toArray()
|
|
.map((e) => Cheerio.load(e).html());
|
|
return {
|
|
title: article('.entry-title').text(),
|
|
description: imgs.concat(txt).join(''),
|
|
pubDate: parseDate(article('time')[0].attribs.datetime),
|
|
link,
|
|
};
|
|
}
|
|
module.exports = loadArticle;
|