diff --git a/lib/routes/universities/hit/today.js b/lib/routes/universities/hit/today.js index e4f532f151..96e397b5d4 100644 --- a/lib/routes/universities/hit/today.js +++ b/lib/routes/universities/hit/today.js @@ -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));