@@ -125,8 +125,15 @@ module.exports = async (ctx) => {
|
||||
const $ = cheerio.load(response.data);
|
||||
// 文字内容
|
||||
const content = $('#articleBody').html();
|
||||
const offset = content.indexOf('</center>'); // 删除标题
|
||||
const description = content.substr(offset + 9).trim();
|
||||
let offset = content.indexOf('</center>'); // 删除标题
|
||||
let description = content.substr(offset + 9).trim();
|
||||
|
||||
// 删除“单 位:XXXXXX”
|
||||
const startIndex = description.indexOf('单 位:') + 4;
|
||||
if (startIndex > 0 && startIndex < 50) {
|
||||
offset = description.indexOf('<br>', 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);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user