feat(route): add Samsung Research Blog (#10081)

* feat(route): add Samsung Research Blog

* fix: add hashTags to categories
This commit is contained in:
Ethan Shen
2022-06-30 23:39:49 +08:00
committed by GitHub
parent 0815cc3b22
commit cffdd8fb29
6 changed files with 80 additions and 0 deletions
+6
View File
@@ -568,6 +568,12 @@ Compared to the official one, this feed:
<RouteEn author="nczitzk" example="/rss3/blog" path="/rss3/blog"/>
## Samsung
### Research Blog
<RouteEn author="nczitzk" example="/samsung/research/blog" path="/samsung/research/blog"/>
## Semiconductor Industry Association
### Latest News
+6
View File
@@ -1128,6 +1128,12 @@ IPFS 网关有可能失效,那时候换成其他网关。
<Route author="nczitzk" example="/rss3/blog" path="/rss3/blog"/>
## Samsung
### Research Blog
<Route author="nczitzk" example="/samsung/research/blog" path="/samsung/research/blog"/>
## Simons Foundation
### 文章
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/research/blog': ['nczitzk'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'samsung.com': {
_name: 'Samsung',
research: [
{
title: 'Research Blog',
docs: 'https://docs.rsshub.app/new-media.html#samsung-research-blog',
source: ['/blog', '/'],
target: '/samsung/research/blog',
},
],
},
};
+49
View File
@@ -0,0 +1,49 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const rootUrl = 'https://research.samsung.com';
const currentUrl = `${rootUrl}/blogMain/list.json`;
const response = await got({
method: 'post',
url: currentUrl,
json: {
currentPageNo: 0,
endIndex: 9,
startIndex: 0,
},
});
let items = response.data.value.map((item) => ({
title: item.title,
author: item.authorName,
link: `${rootUrl}${item.urlLink}`,
category: [item.catagoryCode, item.hashTag1, item.hashTag2],
pubDate: parseDate(item.publicationDtsStr.replace(/On /, ''), 'MMMM D, YYYY'),
}));
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('.news-con').html();
return item;
})
)
);
ctx.state.data = {
title: 'BLOG | Samsung Research',
link: `${rootUrl}/blog`,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/research/blog', require('./research/blog'));
};