diff --git a/lib/routes/universities/fzu/jxtz.js b/lib/routes/universities/fzu/jxtz.js index 6aa8c3b563..02fc8f5a06 100644 --- a/lib/routes/universities/fzu/jxtz.js +++ b/lib/routes/universities/fzu/jxtz.js @@ -1,4 +1,5 @@ const got = require('@/utils/got'); +const cheerio = require('cheerio'); module.exports = async (ctx) => { const response = await got({ method: 'get', @@ -9,15 +10,57 @@ module.exports = async (ctx) => { }); const data = response.data.data; + const urls = []; + for (const key of data) { + urls.push(key.url); + }; + + const mains = []; + for (const key of urls) { + const response = await got(key); + const data1 = response.data; + const $ = cheerio.load(data1); + $('.padTB15').remove(); + $('.c-txt').remove(); + const main = $('.xl_main'); + mains.push(main.html()); + } + + /* + const mains = []; + await Promise.all(urls.map(async (item) => { + console.log(item); + const response = await got({ + method: 'get', + url: item, + headers: { + Referer: `http://jwch.fzu.edu.cn/jxtz/`, + }, + }); + const data1 = response.data; + const $ = cheerio.load(data1); + $('.padTB15').remove(); + $('.c-txt').remove(); + const main = $('.xl_main'); + console.log(item); + mains.push(main.html()); + return mains; + })); + */ + + let i = -1; ctx.state.data = { title: `福州大学教务处教学通知`, link: `http://jwch.fzu.edu.cn/jxtz/`, description: `福州大学教务处教学通知`, - item: data.map((item) => ({ - title: item.title, - description: `${item.title}`, - pubDate: `${item.adddate}`, - link: `${item.url}`, - })), + item: data.map((item) => { + i++; + return { + title: item.title, + description: `${mains[i]}`, + pubDate: `${item.adddate}`, + link: `${item.url}`, + }; + }), }; }; diff --git a/lib/routes/universities/fzu/zjjz.js b/lib/routes/universities/fzu/zjjz.js index d61f14bb70..e3fc1d416a 100644 --- a/lib/routes/universities/fzu/zjjz.js +++ b/lib/routes/universities/fzu/zjjz.js @@ -1,4 +1,5 @@ const got = require('@/utils/got'); +const cheerio = require('cheerio'); module.exports = async (ctx) => { const response = await got({ method: 'get', @@ -9,15 +10,57 @@ module.exports = async (ctx) => { }); const data = response.data.data; + const urls = []; + for (const key of data) { + urls.push(key.url); + }; + + const mains = []; + for (const key of urls) { + const response = await got(key); + const data1 = response.data; + const $ = cheerio.load(data1); + $('.padTB15').remove(); + $('.c-txt').remove(); + const main = $('.xl_main'); + mains.push(main.html()); + } + + /* + const mains = []; + await Promise.all(urls.map(async (item) => { + console.log(item); + const response = await got({ + method: 'get', + url: item, + headers: { + Referer: `http://jwch.fzu.edu.cn/jxtz/`, + }, + }); + const data1 = response.data; + const $ = cheerio.load(data1); + $('.padTB15').remove(); + $('.c-txt').remove(); + const main = $('.xl_main'); + console.log(item); + mains.push(main.html()); + return mains; + })); + */ + + let i = -1; ctx.state.data = { title: `福州大学教务处专家讲座`, link: `http://jwch.fzu.edu.cn/zjjz/`, description: `福州大学教务处加锡讲坛/信息素养讲座通知`, - item: data.map((item) => ({ - title: item.title, - description: `${item.title}`, - pubDate: `${item.adddate}`, - link: `${item.url}`, - })), + item: data.map((item) => { + i++; + return { + title: item.title, + description: `${mains[i]}`, + pubDate: `${item.adddate}`, + link: `${item.url}`, + }; + }), }; };