diff --git a/lib/v2/nua/dc.js b/lib/v2/nua/dc.js index bf7c5e2fbe..247bb9a4bf 100644 --- a/lib/v2/nua/dc.js +++ b/lib/v2/nua/dc.js @@ -41,14 +41,13 @@ module.exports = async (ctx) => { throw Error(`暂不支持对${type}的订阅`); } - const items = await util.ProcessList(baseUrl, baseUrl, listName, listDate); - const pageName = await util.ProcessPageName(baseUrl, webPageName); - const results = await util.ProcessFeed(items, artiContent, ctx.cache); + const items = await util.ProcessList(baseUrl, baseUrl, listName, listDate,webPageName); + const results = await util.ProcessFeed(items[0], artiContent, ctx.cache); ctx.state.data = { - title: 'NUA-设计学院-' + pageName, + title: 'NUA-设计学院-' + items[1], link: baseUrl, - description: '南京艺术学院 设计学院 ' + pageName, + description: '南京艺术学院 设计学院 ' + items[1], item: results, }; }; diff --git a/lib/v2/nua/gra.js b/lib/v2/nua/gra.js index 1f3f96270d..4a80156e8b 100644 --- a/lib/v2/nua/gra.js +++ b/lib/v2/nua/gra.js @@ -9,14 +9,13 @@ module.exports = async (ctx) => { const listDate = '.Article_PublishDate'; const webPageName = '.col_title'; - const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate); - const pageName = await util.ProcessPageName(newsUrl, webPageName); - const results = await util.ProcessFeed(items, artiContent, ctx.cache); + const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName); + const results = await util.ProcessFeed(items[0], artiContent, ctx.cache); ctx.state.data = { - title: 'NUA-研究生处-' + pageName, + title: 'NUA-研究生处-' + items[1], link: `${baseUrl}/${type}/list.htm`, - description: '南京艺术学院 研究生处 ' + pageName, + description: '南京艺术学院 研究生处 ' + items[1], item: results, }; }; diff --git a/lib/v2/nua/index.js b/lib/v2/nua/index.js index 344895ef18..a50b524816 100644 --- a/lib/v2/nua/index.js +++ b/lib/v2/nua/index.js @@ -10,14 +10,13 @@ module.exports = async (ctx) => { const webPageName = '.col_title'; const artiContent = '.read'; - const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate); - const pageName = await util.ProcessPageName(newsUrl, webPageName); - const results = await util.ProcessFeed(items, artiContent, ctx.cache); + const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName); + const results = await util.ProcessFeed(items[0], artiContent, ctx.cache); ctx.state.data = { - title: 'NUA-' + pageName, + title: 'NUA-' + items[1], link: newsUrl, - description: '南京艺术学院 ' + pageName, + description: '南京艺术学院 ' + items[1], item: results, }; }; diff --git a/lib/v2/nua/sxw.js b/lib/v2/nua/sxw.js index 6421c0bac3..dc2d454901 100644 --- a/lib/v2/nua/sxw.js +++ b/lib/v2/nua/sxw.js @@ -10,14 +10,13 @@ module.exports = async (ctx) => { const webPageName = '.Column_Anchor'; const artiContent = '.read'; - const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate); - const pageName = await util.ProcessPageName(newsUrl, webPageName); - const results = await util.ProcessFeed(items, artiContent, ctx.cache); + const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName); + const results = await util.ProcessFeed(items[0], artiContent, ctx.cache); ctx.state.data = { - title: 'NUA-双馨网-' + pageName, + title: 'NUA-双馨网-' + items[1], link: newsUrl, - description: '南京艺术学院 双馨网 ' + pageName, + description: '南京艺术学院 双馨网 ' + items[1], item: results, }; }; diff --git a/lib/v2/nua/utils.js b/lib/v2/nua/utils.js index 4b64efcf1e..ee3fb34b42 100644 --- a/lib/v2/nua/utils.js +++ b/lib/v2/nua/utils.js @@ -3,7 +3,7 @@ const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); const timezone = require('@/utils/timezone'); -async function ProcessList(newsUrl, baseUrl, listName, listDate) { +async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) { const result = await got(newsUrl, { https: { rejectUnauthorized: false, @@ -11,6 +11,8 @@ async function ProcessList(newsUrl, baseUrl, listName, listDate) { }); const $ = cheerio.load(result.data); + const pageName = $(webPageName).text(); + let artiLink; const items = $(listName) @@ -30,20 +32,7 @@ async function ProcessList(newsUrl, baseUrl, listName, listDate) { }; }); - return items; -} - -async function ProcessPageName(newsUrl, webPageName) { - const result = await got(newsUrl, { - https: { - rejectUnauthorized: false, - }, - }); - const $ = cheerio.load(result.data); - - const pageName = $(webPageName).text(); - - return pageName; + return [items, pageName]; } const ProcessFeed = async (items, artiContent, cache) => @@ -67,6 +56,5 @@ const ProcessFeed = async (items, artiContent, cache) => module.exports = { ProcessList, - ProcessPageName, ProcessFeed, };