mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
feat: add 三星盖乐世社区最新帖子 (#4887)
This commit is contained in:
@@ -241,6 +241,12 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="junfengP" example="/nowcoder/schedule" path="nowcoder/schedule/:propertyId?/:typeId?" :paramsDesc="['行业, 在控制台中抓取接口,可获得行业id,默认0', '类别,同上']" />
|
<Route author="junfengP" example="/nowcoder/schedule" path="nowcoder/schedule/:propertyId?/:typeId?" :paramsDesc="['行业, 在控制台中抓取接口,可获得行业id,默认0', '类别,同上']" />
|
||||||
|
|
||||||
|
## 三星盖乐世社区
|
||||||
|
|
||||||
|
### 最新帖子
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/samsungmembers/latest" path="/samsungmembers/latest"/>
|
||||||
|
|
||||||
## 书友社区
|
## 书友社区
|
||||||
|
|
||||||
### 导读
|
### 导读
|
||||||
|
|||||||
@@ -2799,6 +2799,9 @@ router.get('/law/jh', require('./routes/law/jh'));
|
|||||||
// Mobilism
|
// Mobilism
|
||||||
router.get('/mobilism/release', require('./routes/mobilism/release'));
|
router.get('/mobilism/release', require('./routes/mobilism/release'));
|
||||||
|
|
||||||
|
// 三星盖乐世社区
|
||||||
|
router.get('/samsungmembers/latest', require('./routes/samsungmembers/latest'));
|
||||||
|
|
||||||
// 东莞教研网
|
// 东莞教研网
|
||||||
router.get('/dgjyw/:type', require('./routes/dgjyw/index'));
|
router.get('/dgjyw/:type', require('./routes/dgjyw/index'));
|
||||||
|
|
||||||
|
|||||||
42
lib/routes/samsungmembers/latest.js
Normal file
42
lib/routes/samsungmembers/latest.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
const url = require('url');
|
||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const currentUrl = 'http://www.samsungmembers.cn/bbs/';
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: currentUrl,
|
||||||
|
});
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const list = $('div.ImgList dl dt')
|
||||||
|
.slice(0, 15)
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const a = item.find('a');
|
||||||
|
return {
|
||||||
|
title: a.text(),
|
||||||
|
link: url.resolve('http://www.samsungmembers.cn/', a.attr('href')),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(
|
||||||
|
async (item) =>
|
||||||
|
await ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const res = await got({ method: 'get', url: item.link });
|
||||||
|
const content = cheerio.load(res.data);
|
||||||
|
item.pubDate = new Date(content('p.data').text() + ' GMT+8').toUTCString();
|
||||||
|
item.description = content('div.BSHARE_POP').html();
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '三星盖乐世社区 - 最新帖子',
|
||||||
|
link: currentUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user