forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #822 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
12 changed files
with
185 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const got = require('@/utils/got'); | ||
const utils = require('./utils'); | ||
|
||
const typeMap = { | ||
351: { | ||
name: '名师风采', | ||
}, | ||
353: { | ||
name: '热点新闻', | ||
}, | ||
354: { | ||
name: '教务公告', | ||
}, | ||
355: { | ||
name: '教学新闻', | ||
}, | ||
}; | ||
|
||
module.exports = async (ctx) => { | ||
const page = ctx.params.page || '12'; | ||
const base = utils.columnIdBase(ctx.params.type) + '&pagingNumberPer=' + page; | ||
const res = await got(base); | ||
const info = utils.fetchAllArticle(res.data, utils.JWZXBASE); | ||
|
||
const details = await Promise.all(info.map((e) => utils.detailPage(e, ctx.cache))); | ||
|
||
// ctx.state.json = { | ||
// info, | ||
// }; | ||
|
||
ctx.state.data = { | ||
title: '哈理工教务处' + typeMap[ctx.params.type || 354].name, | ||
link: base, | ||
item: details, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/jwzx/:type?/:page?': ['LenaNouzen'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'hrbust.edu.cn': { | ||
_name: '哈尔滨理工大学', | ||
jwzx: [ | ||
{ | ||
title: '教务处', | ||
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-li-gong-da-xue', | ||
source: '/homepage/*', | ||
target: (params, url) => `/hrbust/jwzx/${url.match(/(?<=columnId=)\d+/)}`, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (router) { | ||
router.get('/jwzx/:type?/:page?', require('./jwzx')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{@ desc }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const cheerio = require('cheerio'); | ||
const got = require('@/utils/got'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const timezone = require('@/utils/timezone'); | ||
|
||
// const base = 'http://hrbust.edu.cn'; | ||
const jwzxBase = 'http://jwzx.hrbust.edu.cn/homepage/'; | ||
|
||
const columnIdBase = (id) => (id ? `${jwzxBase}infoArticleList.do?columnId=${id}` : `${jwzxBase}infoArticleList.do?columnId=354`); | ||
|
||
const renderDesc = (desc) => | ||
art(path.join(__dirname, 'templates/description.art'), { | ||
desc, | ||
}); | ||
|
||
const detailPage = (e, cache) => | ||
cache.tryGet(e.detailPage, async () => { | ||
const result = await got(e.detailPage); | ||
const $ = cheerio.load(result.data); | ||
const title = $('div#article h2').text().trim(); | ||
const desc = | ||
$('div.body').html() && | ||
$('div.body') | ||
.html() | ||
.replace(/style="(.*?)"/g, '') | ||
.trim(); | ||
const pubDate = timezone( | ||
parseDate( | ||
$('div#articleInfo ul li') | ||
.first() | ||
.text() | ||
.replace(/发布日期:/g, '') | ||
.trim() | ||
), | ||
+8 | ||
); | ||
return { | ||
title: e.title || title, | ||
description: renderDesc(desc), | ||
link: e.detailPage, | ||
pubDate: e.pubDate || pubDate, | ||
}; | ||
}); | ||
|
||
const fetchAllArticle = (data, base) => { | ||
const $ = cheerio.load(data); | ||
const article = $('.articleList li div'); | ||
const info = article | ||
.map((i, e) => { | ||
const c = cheerio.load(e); | ||
const r = { | ||
title: c('a').first().text().trim(), | ||
detailPage: new URL(c('a').attr('href'), base).href, | ||
pubDate: timezone(parseDate(c('span').first().text().trim()), +8), | ||
}; | ||
return r; | ||
}) | ||
.get(); | ||
return info; | ||
}; | ||
|
||
module.exports = { | ||
// BASE: base, | ||
JWZXBASE: jwzxBase, | ||
columnIdBase, | ||
fetchAllArticle, | ||
detailPage, | ||
renderDesc, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const utils = require('./utils'); | ||
const got = require('@/utils/got'); | ||
|
||
const sections = { | ||
hotNews: '澎湃热榜', | ||
financialInformationNews: '澎湃财讯', | ||
morningEveningNews: '早晚报', | ||
}; | ||
|
||
module.exports = async (ctx) => { | ||
const { sec = 'hotNews' } = ctx.params; | ||
|
||
const sidebar_url = `https://cache.thepaper.cn/contentapi/wwwIndex/rightSidebar`; | ||
const sidebar_url_resp = await got(sidebar_url); | ||
const sidebar_url_data = sidebar_url_resp.data; | ||
const list = sidebar_url_data.data[sec]; | ||
|
||
const items = await Promise.all(list.filter((item) => item.contId).map((item) => utils.ProcessItem(item, ctx))); | ||
ctx.state.data = { | ||
title: `澎湃新闻 - ${sections[sec]}`, | ||
item: items, | ||
link: 'https://www.thepaper.cn', | ||
}; | ||
}; |
b2efd59
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsshub-master – ./
rsshub-master-git-master-auto-bot-ty.vercel.app
rsshub-master.vercel.app
rsshub-master-auto-bot-ty.vercel.app