diff --git a/lib/routes/universities/gdut/news.js b/lib/routes/universities/gdut/news.js index 029797177..ab9d21425 100644 --- a/lib/routes/universities/gdut/news.js +++ b/lib/routes/universities/gdut/news.js @@ -125,8 +125,15 @@ module.exports = async (ctx) => { const $ = cheerio.load(response.data); // 文字内容 const content = $('#articleBody').html(); - const offset = content.indexOf(''); // 删除标题 - const description = content.substr(offset + 9).trim(); + let offset = content.indexOf(''); // 删除标题 + let description = content.substr(offset + 9).trim(); + + // 删除“单 位:XXXXXX” + const startIndex = description.indexOf('单 位:') + 4; + if (startIndex > 0 && startIndex < 50) { + offset = description.indexOf('
', startIndex) + 4; + description = description.substr(offset).trim(); + } // 获取文章数据 const articleinfos = $('.articleinfos').text(); @@ -142,6 +149,7 @@ module.exports = async (ctx) => { author: author, category: category, }; + // 将文章结果缓存 ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single); })