diff --git a/docs/other.md b/docs/other.md index 27567f2fb6..fa87b28e54 100644 --- a/docs/other.md +++ b/docs/other.md @@ -1257,6 +1257,12 @@ type 为 all 时,category 参数不支持 cost 和 free +## 智联招聘 + +### 搜索 + + + ## 中国大学 MOOC(慕课) ### 最新 diff --git a/docs/university.md b/docs/university.md index f6a5303262..8bb28890f1 100644 --- a/docs/university.md +++ b/docs/university.md @@ -24,6 +24,20 @@ pageClass: routes +## 北华航天工业学院 + +### 新闻 + + + +### 学术信息 + + + +### 通知公告 + + + ## 北京大学 ### 信科公告通知 diff --git a/lib/router.js b/lib/router.js index 19a0b96ceb..6db528610b 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1653,6 +1653,18 @@ router.get('/cneb/guoneinews', require('./routes/cneb/guoneinews')); // 邮箱 router.get('/mail/imap/:email', require('./routes/mail/imap')); +// 智联招聘 +router.get('/zhilian/:city/:keyword', require('./routes/zhilian/index')); + +// 北华航天工业学院 - 新闻 +router.get('/nciae/news', require('./routes/universities/nciae/news')); + +// 北华航天工业学院 - 通知公告 +router.get('/nciae/tzgg', require('./routes/universities/nciae/tzgg')); + +// 北华航天工业学院 - 学术信息 +router.get('/nciae/xsxx', require('./routes/universities/nciae/xsxx')); + // cfan router.get('/cfan/news', require('./routes/cfan/news')); diff --git a/lib/routes/gov/veterans/index.js b/lib/routes/gov/veterans/index.js index 1a07ab61a0..ec63b39beb 100644 --- a/lib/routes/gov/veterans/index.js +++ b/lib/routes/gov/veterans/index.js @@ -43,21 +43,16 @@ module.exports = async (ctx) => { url: page, }); const data = response.data; - const fs = require('fs'); - fs.writeFile('result.txt', data, function(err) { - if (err) { - return console.error(err); - } - }); const $ = cheerio.load(data); const list = $('#whTopSlide > div.bd > ul > li > a').get(); - console.log(list.length); const process = await Promise.all( list.map(async (item) => { let itemUrl = $(item).attr('href'); if (itemUrl.indexOf('./') === 0) { - itemUrl = host + itemUrl.substring(2); + itemUrl = host + itemUrl.substring(1); + } else if (itemUrl.indexOf('/') === 0) { + itemUrl = host + itemUrl; } const single = { title: $(item).attr('title'), diff --git a/lib/routes/kaiyan/index.js b/lib/routes/kaiyan/index.js index d8fd59a030..7f4528cf08 100644 --- a/lib/routes/kaiyan/index.js +++ b/lib/routes/kaiyan/index.js @@ -1,40 +1,43 @@ const got = require('@/utils/got'); module.exports = async (ctx) => { - // const id = ctx.params.id; const api_url = `https://baobab.kaiyanapp.com/api/v5/index/tab/allRec`; const response = await got({ method: 'get', url: api_url, }); + // ## 获取列表 const list = response.data.itemList[0].data.itemList; + // ## 定义输出的item const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 list.map(async (item) => { if (item.type === 'followCard') { - // 截取Json一部分 + // #### 截取Json中需要的部分,便于下方变量快速取值 const content = item.data.content; - // 得到需要的RSS信息 + // #### 得到需要的RSS信息 const title = content.data.title; // 标题 const date = item.data.header.time; // 发布日期 + const videoUrl = content.data.playUrl; // 原装视频链接 const itemUrl = ``; // 视频链接 const imgUrl = ``; // 图片链接 const author = content.data.author.name; // 作者 - const description = content.data.description + '
' + imgUrl + '
' + itemUrl; // 拼接出描述 + const description = content.data.description + '
' + imgUrl + '
' + itemUrl; // 拼接出详情,包括文字描述、封面图、视频链接 - const cache = await ctx.cache.get(itemUrl); // 得到全局中的缓存信息 - // 判断缓存是否存在,如果存在即跳过此次获取的信息 + const cache = await ctx.cache.get(itemUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 if (cache) { return Promise.resolve(JSON.parse(cache)); } - // 设置 RSS feed item + // ### 设置 RSS feed item const single = { title: title, - link: itemUrl, + link: videoUrl, author: author, description: description, pubDate: new Date(date).toUTCString(), }; - // 设置缓存 + // ### 设置缓存 ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); } diff --git a/lib/routes/universities/nciae/news.js b/lib/routes/universities/nciae/news.js new file mode 100644 index 0000000000..124fc6e9c0 --- /dev/null +++ b/lib/routes/universities/nciae/news.js @@ -0,0 +1,58 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `http://nciae.edu.cn/index/xw2.htm`; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + // ## 获取列表 + const list = $('#container > ul > li > a').get(); + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const itemSingle = cheerio.load(item); + const title = itemSingle.text(); + const re = /]*href=['"]([^"]*)['"][^>]*>(.*?)<\/a>/g; + let singleUrl = ''; + if (re.exec(itemSingle.html()) !== null) { + singleUrl = RegExp.$1; + } + singleUrl = singleUrl.replace('..', 'http://nciae.edu.cn'); + const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: singleUrl, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('#content > form').html(); + // ### 设置 RSS feed item + const single = { + title: title, + link: singleUrl, + // author: author, + description: detail_content, + // pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(singleUrl, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + + ctx.state.data = { + title: `新闻 - 北华航天工业学院`, + link: 'http://nciae.edu.cn/index/xw2.htm', + description: `新闻 - 北华航天工业学院`, + item: out, + }; +}; diff --git a/lib/routes/universities/nciae/tzgg.js b/lib/routes/universities/nciae/tzgg.js new file mode 100644 index 0000000000..467e38133d --- /dev/null +++ b/lib/routes/universities/nciae/tzgg.js @@ -0,0 +1,58 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `http://nciae.edu.cn/index/tzgg.htm`; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + // ## 获取列表 + const list = $('#container > ul > li > a').get(); + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const itemSingle = cheerio.load(item); + const title = itemSingle.text(); + const re = /]*href=['"]([^"]*)['"][^>]*>(.*?)<\/a>/g; + let singleUrl = ''; + if (re.exec(itemSingle.html()) !== null) { + singleUrl = RegExp.$1; + } + singleUrl = singleUrl.replace('..', 'http://nciae.edu.cn'); + const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: singleUrl, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('#content > form').html(); + // ### 设置 RSS feed item + const single = { + title: title, + link: singleUrl, + // author: author, + description: detail_content, + // pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(singleUrl, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + + ctx.state.data = { + title: `通知公告 - 北华航天工业学院`, + link: 'http://nciae.edu.cn/index/xw2.htm', + description: `通知公告 - 北华航天工业学院`, + item: out, + }; +}; diff --git a/lib/routes/universities/nciae/xsxx.js b/lib/routes/universities/nciae/xsxx.js new file mode 100644 index 0000000000..d5d4c36210 --- /dev/null +++ b/lib/routes/universities/nciae/xsxx.js @@ -0,0 +1,58 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = `http://nciae.edu.cn/index/xsxx.htm`; + const response = await got({ + method: 'get', + url: url, + }); + const $ = cheerio.load(response.data); + // ## 获取列表 + const list = $('#container > ul > li > a').get(); + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const itemSingle = cheerio.load(item); + const title = itemSingle.text(); + const re = /]*href=['"]([^"]*)['"][^>]*>(.*?)<\/a>/g; + let singleUrl = ''; + if (re.exec(itemSingle.html()) !== null) { + singleUrl = RegExp.$1; + } + singleUrl = singleUrl.replace('..', 'http://nciae.edu.cn'); + const cache = await ctx.cache.get(singleUrl); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: singleUrl, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('#content > form').html(); + // ### 设置 RSS feed item + const single = { + title: title, + link: singleUrl, + // author: author, + description: detail_content, + // pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(singleUrl, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + + ctx.state.data = { + title: `学术信息 - 北华航天工业学院`, + link: 'http://nciae.edu.cn/index/xw2.htm', + description: `学术信息 - 北华航天工业学院`, + item: out, + }; +}; diff --git a/lib/routes/zhilian/index.js b/lib/routes/zhilian/index.js new file mode 100644 index 0000000000..4509a63df1 --- /dev/null +++ b/lib/routes/zhilian/index.js @@ -0,0 +1,80 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const city = ctx.params.city; + const keyword = ctx.params.keyword; + const city_api_url = `https://fe-api.zhaopin.com/c/i/city-page/user-city?ipCity=${encodeURI(city)}`; + + const city_response = await got({ + method: 'get', + url: city_api_url, + }); + const city_response_data = city_response.data.data; + if (city_response_data.name === undefined) { + console.log('No This City'); + } else { + const job_api_url = `https://fe-api.zhaopin.com/c/i/sou?pageSize=20&cityId=${city_response_data.code}&workExperience=-1&education=5&companyType=-1&employmentType=-1&jobWelfareTag=-1&kw=${encodeURI(keyword)}&kt=3`; + const job_response = await got({ + method: 'get', + url: job_api_url, + }); + + // ## 获取列表 + const list = job_response.data.data.results; + // ## 定义输出的item + const out = await Promise.all( + // ### 遍历列表,筛选出自己想要的内容 + list.map(async (item) => { + const jobName = item.jobName; + const companyName = item.company.name; + const companyType = item.company.type.name; + const companySize = item.company.size.name; + const companyUrl = item.company.url; + const companyLogo = item.companyLogo; // logo + const salary = item.salary; + const jobType = item.jobType.items[0].name; + const positionURL = item.positionURL; // 原网页链接 + const updateDate = item.updateDate; // 更新时间 + + // 获取详情页面的介绍 + const detail_response = await got({ + method: 'get', + url: positionURL, + }); + const $ = cheerio.load(detail_response.data); + const detail_content = $('.describtion').html(); + // # 拼接相关信息 + // ## 拼接标题 + const title = `${jobName}[${salary}]-${jobType}`; + // ## 公司信息 + const companyDes = `

${companyName}

${companyType}[${companySize}]

点击查看公司详情
`; + const cache_information = positionURL + updateDate; // 确保唯一性 + const cache = await ctx.cache.get(cache_information); // ### 得到全局中的缓存信息 + // ### 判断缓存是否存在,如果存在即跳过此次获取的信息 + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + // ### 设置 RSS feed item + const single = { + title: title, + link: positionURL, + // author: author, + description: `如需申请此工作,建议打开原网页进行操作。

${companyDes}

${detail_content !== null ? detail_content : ''}`, + pubDate: updateDate, + }; + // // ### 设置缓存 + ctx.cache.set(cache_information, JSON.stringify(single)); + return Promise.resolve(single); + // } + }) + ); + + ctx.state.data = { + title: `${city}-${keyword} 相关工作 - 智联招聘`, + link: '', + description: `${city} 的 ${keyword} 相关工作 - 智联招聘`, + item: out, + }; + } +};