From 0be82b2dd441e99606ff91a30f58c1dbcc983cf4 Mon Sep 17 00:00:00 2001 From: Queensferry Date: Tue, 23 Feb 2021 08:08:31 +0800 Subject: [PATCH] fix(route): pianyuan domain changes (#6951) * fix: format errors in `/sustech/bidding` and `/sustech/newshub-zh` also see * fix: pianyuan domain changes (#6904) Co-authored-by: NeverBehave --- lib/routes/furaffinity/journals.js | 2 +- lib/routes/pianyuan/app.js | 2 +- lib/routes/universities/sustech/bidding.js | 52 +++++++++--------- lib/routes/universities/sustech/newshub-zh.js | 53 +++++++++---------- 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/lib/routes/furaffinity/journals.js b/lib/routes/furaffinity/journals.js index 4c8de7ce7..d62b96104 100644 --- a/lib/routes/furaffinity/journals.js +++ b/lib/routes/furaffinity/journals.js @@ -17,7 +17,7 @@ module.exports = async (ctx) => { // 使用 cheerio 加载返回的 HTML const data = response.data; const $ = cheerio.load(data, { - xmlMode: true + xmlMode: true, }); const list = $('item'); diff --git a/lib/routes/pianyuan/app.js b/lib/routes/pianyuan/app.js index c4fd09b85..bb4d8ec65 100644 --- a/lib/routes/pianyuan/app.js +++ b/lib/routes/pianyuan/app.js @@ -3,7 +3,7 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const media = ctx.params.media || -1; - const link_base = 'http://pianyuan.la/'; + const link_base = 'http://pianyuan.tv/'; let description = '电影和剧集'; let link = link_base; if (media !== -1) { diff --git a/lib/routes/universities/sustech/bidding.js b/lib/routes/universities/sustech/bidding.js index fd476a378..2d4e74396 100644 --- a/lib/routes/universities/sustech/bidding.js +++ b/lib/routes/universities/sustech/bidding.js @@ -2,35 +2,33 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: 'http://biddingoffice.sustech.edu.cn/', - }); + const response = await got({ + method: 'get', + url: 'http://biddingoffice.sustech.edu.cn/', + }); - const data = response.data; + const data = response.data; - const $ = cheerio.load(data); + const $ = cheerio.load(data); - const list = $('.index-wrap.index-2 ul li'); + const list = $('.index-wrap.index-2 ul li'); - - ctx.state.data = { - title: '南方科技大学采购与招标管理部', - link: 'http://biddingoffice.sustech.edu.cn/', - item: - list && - list - .map((index, item) => { - item = $(item); - itemPicUrl = `${item.find('div > a:nth-child(1) > img').attr('herf')}`; - itemPubdate = item.find('li > span').text(); - return { - pubDate: itemPubdate, - title: item.find('li > a').text(), - description: item.find('li > a').text(), - link: item.find('li > a').attr('href'), - }; - }) - .get(), - }; + ctx.state.data = { + title: '南方科技大学采购与招标管理部', + link: 'http://biddingoffice.sustech.edu.cn/', + item: + list && + list + .map((index, item) => { + item = $(item); + const itemPubdate = item.find('li > span').text(); + return { + pubDate: itemPubdate, + title: item.find('li > a').text(), + description: item.find('li > a').text(), + link: item.find('li > a').attr('href'), + }; + }) + .get(), + }; }; diff --git a/lib/routes/universities/sustech/newshub-zh.js b/lib/routes/universities/sustech/newshub-zh.js index 02cd576a3..b877fc5f9 100644 --- a/lib/routes/universities/sustech/newshub-zh.js +++ b/lib/routes/universities/sustech/newshub-zh.js @@ -2,35 +2,34 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: 'https://newshub.sustech.edu.cn/zh/news/', - }); + const response = await got({ + method: 'get', + url: 'https://newshub.sustech.edu.cn/zh/news/', + }); - const data = response.data; + const data = response.data; - const $ = cheerio.load(data); + const $ = cheerio.load(data); - const list = $('.m-newslist ul li'); + const list = $('.m-newslist ul li'); - - ctx.state.data = { - title: '南方科技大学新闻网-中文', - link: 'https://newshub.sustech.edu.cn/zh/news/', - item: - list && - list - .map((index, item) => { - item = $(item); - itemPicUrl = `${item.find('a > div.u-pic').attr('style')}`.replace('background-image:url(', 'https://newshub.sustech.edu.cn/').replace(');', ''); - itemPubdate = item.find('a > div.u-date').text(); - return { - pubDate: itemPubdate, - title: item.find('a > div.u-text > div.title.f-clamp').text(), - description: `
${item.find('a > div.u-text > div.details.f-clamp4 > p').text()}`, - link: item.find('a').attr('href'), - }; - }) - .get(), - }; + ctx.state.data = { + title: '南方科技大学新闻网-中文', + link: 'https://newshub.sustech.edu.cn/zh/news/', + item: + list && + list + .map((index, item) => { + item = $(item); + const itemPicUrl = `${item.find('a > div.u-pic').attr('style')}`.replace('background-image:url(', 'https://newshub.sustech.edu.cn/').replace(');', ''); + const itemPubdate = item.find('a > div.u-date').text(); + return { + pubDate: itemPubdate, + title: item.find('a > div.u-text > div.title.f-clamp').text(), + description: `
${item.find('a > div.u-text > div.details.f-clamp4 > p').text()}`, + link: item.find('a').attr('href'), + }; + }) + .get(), + }; };