mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
feat(route): add Research Gate Publications (#7544)
This commit is contained in:
@@ -372,6 +372,12 @@ Compared to the official one, this feed:
|
|||||||
|
|
||||||
</RouteEn>
|
</RouteEn>
|
||||||
|
|
||||||
|
## Research Gate
|
||||||
|
|
||||||
|
### Publications
|
||||||
|
|
||||||
|
<RouteEn author="nczitzk" example="/researchgate/publications/Somsak-Panha" path="/researchgate/publications/:username" :paramsDesc="['Username, can be found in URL']"/>
|
||||||
|
|
||||||
## Semiconductor Industry Association
|
## Semiconductor Industry Association
|
||||||
|
|
||||||
### Latest News
|
### Latest News
|
||||||
|
|||||||
@@ -633,6 +633,12 @@ IPFS 网关有可能失效,那时候换成其他网关。
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## Research Gate
|
||||||
|
|
||||||
|
### Publications
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/researchgate/publications/Somsak-Panha" path="/researchgate/publications/:username" :paramsDesc="['用户名,可在用户页地址栏中找到']"/>
|
||||||
|
|
||||||
## Simons Foundation
|
## Simons Foundation
|
||||||
|
|
||||||
### 文章
|
### 文章
|
||||||
|
|||||||
@@ -4212,4 +4212,7 @@ router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai'));
|
|||||||
|
|
||||||
// Deprecated: DO NOT ADD ROUTE HERE
|
// Deprecated: DO NOT ADD ROUTE HERE
|
||||||
|
|
||||||
|
// Research Gate
|
||||||
|
router.get('/researchgate/publications/:id', require('./routes/researchgate/publications'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
60
lib/routes/researchgate/publications.js
Normal file
60
lib/routes/researchgate/publications.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const id = ctx.params.id;
|
||||||
|
|
||||||
|
const rootUrl = 'https://www.researchgate.net';
|
||||||
|
const currentUrl = `${rootUrl}/profile/${id}`;
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: currentUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const list = $('div[itemprop="headline"] a')
|
||||||
|
.slice(0, 15)
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
return {
|
||||||
|
title: item.text(),
|
||||||
|
link: item.attr('href'),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(
|
||||||
|
async (item) =>
|
||||||
|
await ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
});
|
||||||
|
const content = cheerio.load(detailResponse.data);
|
||||||
|
|
||||||
|
item.doi = content('meta[property="citation_doi"]').attr('content');
|
||||||
|
item.pubDate = Date.parse(content('meta[property="citation_publication_date"]').attr('content'));
|
||||||
|
|
||||||
|
const authors = [];
|
||||||
|
|
||||||
|
content('meta[property="citation_author"]').each(function () {
|
||||||
|
authors.push(content(this).attr('content'));
|
||||||
|
});
|
||||||
|
|
||||||
|
item.author = authors.join(', ');
|
||||||
|
|
||||||
|
item.description = content('div[itemprop="description"]').html();
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${$('meta[property="profile:username"]').attr('content')}'s Publications - ResearchGate`,
|
||||||
|
link: currentUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user