From 318a5ac453f9dd3e734aaa4895cb7cfb98ac9192 Mon Sep 17 00:00:00 2001 From: Chenyang Shi Date: Tue, 5 Mar 2019 14:30:03 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=B8=9C=E5=8D=97=E5=A4=A7=E5=AD=A6?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=9C=BA=E6=8A=80=E6=9C=AF=E4=B8=8E=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E5=AD=A6=E9=99=A2=20(#1685)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 网页改版 --- lib/routes/universities/seu/cse/index.js | 25 ++++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/routes/universities/seu/cse/index.js b/lib/routes/universities/seu/cse/index.js index f12c3b272..a1eacfa0d 100644 --- a/lib/routes/universities/seu/cse/index.js +++ b/lib/routes/universities/seu/cse/index.js @@ -3,36 +3,35 @@ const cheerio = require('cheerio'); const url = require('url'); const host = 'http://cse.seu.edu.cn/'; -const noticHost = 'http://cse.seu.edu.cn/CSE/UI/Notice/'; const map = new Map([ - ['xyxw', { title: '东南大学计算机技术与工程学院 -- 学院新闻', suffix: 'Notice.aspx?Notice_Type=0' }], - ['tzgg', { title: '东南大学计算机技术与工程学院 -- 通知公告', suffix: 'Notice.aspx?Notice_Type=1' }], - ['jwxx', { title: '东南大学计算机技术与工程学院 -- 教务信息', suffix: 'Notice.aspx?Notice_Type=2' }], - ['jyxx', { title: '东南大学计算机技术与工程学院 -- 就业信息', suffix: 'Notice.aspx?Notice_Type=3' }], - ['xgsw', { title: '东南大学计算机技术与工程学院 -- 学工事务', suffix: 'Notice.aspx?Notice_Type=4' }], + ['xyxw', { title: '东南大学计算机技术与工程学院 -- 学院新闻', suffix: '22535/list.htm' }], + ['tzgg', { title: '东南大学计算机技术与工程学院 -- 通知公告', suffix: '22536/list.htm' }], + ['jwxx', { title: '东南大学计算机技术与工程学院 -- 教务信息', suffix: '22538/list.htm' }], + ['jyxx', { title: '东南大学计算机技术与工程学院 -- 就业信息', suffix: '22537/list.htm' }], + ['xgsw', { title: '东南大学计算机技术与工程学院 -- 学工事务', suffix: '22539/list.htm' }], ]); module.exports = async (ctx) => { const type = ctx.params.type || 'xyxw'; const suffix = map.get(type).suffix; - const link = url.resolve(noticHost, suffix); + const link = url.resolve(host, suffix); const response = await axios.get(link); const $ = cheerio.load(response.data); - const list = $('table.datatable tbody tr') + const list = $('table.wp_article_list_table tbody tr td > table > tbody > tr') .slice(0, 10) .map(function() { const info = { title: $(this) - .find('td:nth-child(1) a') + .find('div.news_title.fl > a') .attr('title'), link: $(this) - .find('td:nth-child(1) a') + .find('div.news_title.fl > a') .attr('href'), date: $(this) - .find('td:nth-child(2) span') + .find('div.news_time.fr') .text(), }; return info; @@ -43,7 +42,7 @@ module.exports = async (ctx) => { list.map(async (info) => { const title = info.title; const date = info.date; - const itemUrl = url.resolve(noticHost, info.link); + const itemUrl = url.resolve(host, info.link); const cache = await ctx.cache.get(itemUrl); if (cache) { @@ -56,7 +55,7 @@ module.exports = async (ctx) => { const single = { title: title, link: itemUrl, - description: $('.notice-content-wrapper') + description: $('div.wp_articlecontent') .html() .replace(/src="\//g, `src="${url.resolve(host, '.')}`) .trim(),