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.
- Loading branch information
Showing
5 changed files
with
131 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
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,61 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const category = ctx.params.category ?? ''; | ||
|
||
const rootUrl = 'https://www.lianxh.cn'; | ||
const currentUrl = `${rootUrl}/blogs${category ? `/${category}` : ''}.html`; | ||
|
||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
let items = $('.news-title a') | ||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
return { | ||
title: item.text(), | ||
link: `${rootUrl}${item.attr('href')}`, | ||
}; | ||
}); | ||
|
||
items = await Promise.all( | ||
items.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
|
||
const content = cheerio.load(detailResponse.data); | ||
|
||
item.description = content('#nice').html(); | ||
item.pubDate = parseDate( | ||
content('.news-share') | ||
.prev() | ||
.find('span') | ||
.first() | ||
.text() | ||
.match(/(\d+-\d+-\d+)/)[1], | ||
'YYYY-MM-DD' | ||
); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `连享会 - ${$('.actives').text()}`, | ||
link: currentUrl, | ||
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/:category?': ['nczitzk'], | ||
}; |
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 = { | ||
'lianxh.cn': { | ||
_name: '连享会', | ||
'.': [ | ||
{ | ||
title: '精彩资讯', | ||
docs: 'https://docs.rsshub.app/programming.html#lian-xiang-hui-jing-cai-zi-xun', | ||
source: ['/blogs.html', '/'], | ||
target: '/lianxh/:category?', | ||
}, | ||
], | ||
}, | ||
}; |
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('/:category?', require('./index')); | ||
}; |