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.
feat(route): Add qdu houqin (DIYgod#14515)
* feat(route): Add qdu houqin * feat(route): qdu houqin - more accurate time * fix: alphabetical order * fix: unnecessary condition ---------
- Loading branch information
1 parent
88a594e
commit 0d47d01
Showing
5 changed files
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
const base = 'https://houqin.qdu.edu.cn/'; | ||
|
||
module.exports = async (ctx) => { | ||
const response = await got({ | ||
method: 'get', | ||
url: `${base}index/tzgg.htm`, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
const list = $('.n_newslist').children(); | ||
const items = await Promise.all( | ||
list.map((i, item) => { | ||
item = $(item); | ||
const itemTitle = item.find('a').text(); | ||
let itemDate = timezone(parseDate(item.find('span').text()), 8); | ||
const path = item.find('a').attr('href'); | ||
const itemUrl = base + path; | ||
return ctx.cache.tryGet(itemUrl, async () => { | ||
let description = ''; | ||
const result = await got(itemUrl); | ||
const $ = cheerio.load(result.data); | ||
if ( | ||
$('.article_body') | ||
.find('div > h4') | ||
.text() | ||
.match(/发布时间:(.*)编辑:/) !== null | ||
) { | ||
itemDate = timezone( | ||
parseDate( | ||
$('.article_body') | ||
.find('div > h4') | ||
.text() | ||
.match(/发布时间:(.*)编辑:/)[1] | ||
.trim(), | ||
'YYYY年MM月DD日 HH:mm' | ||
), | ||
8 | ||
); | ||
} | ||
description = $('.v_news_content').html().trim(); | ||
|
||
return { | ||
title: itemTitle, | ||
link: itemUrl, | ||
pubDate: itemDate, | ||
description, | ||
}; | ||
}); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: '青岛大学 - 后勤管理处通知', | ||
link: `${base}index/tzgg.htm`, | ||
description: '青岛大学 - 后勤管理处通知', | ||
item: items, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
'/houqin': ['abc1763613206'], | ||
'/jwc': ['abc1763613206'], | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = (router) => { | ||
router.get('/houqin', require('./houqin')); | ||
router.get('/jwc', require('./jwc')); | ||
}; |
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