mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix: 为今日哈工大正文添加格式,提高阅读体验 (#3745)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const host = 'http://today.hit.edu.cn';
|
||||
@@ -62,12 +63,19 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const description =
|
||||
$('.article-content').html() &&
|
||||
$('.article-content')
|
||||
.html()
|
||||
.replace(/src="\//g, `src="${url.resolve(host, '.')}`)
|
||||
.replace(/href="\//g, `href="${url.resolve(host, '.')}`)
|
||||
.trim();
|
||||
const single = {
|
||||
pubDate: new Date($('.left-attr.first').text()).toUTCString(),
|
||||
author: author,
|
||||
link: link,
|
||||
title: title,
|
||||
description: $('.article-content').text(),
|
||||
description: description,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
|
||||
Reference in New Issue
Block a user