feat(route): Add dblp and format my code (#12620)
* Add dblp and format my code * Add rule files for the dblp * doi has been set in publication.js * update files * update files * doi has been set in publication.js
This commit is contained in:
@@ -24,6 +24,12 @@ pageClass: routes
|
||||
|
||||
<RouteEn author="HankChow" example="/cssn/iolaw/zxzp" path="/cssn/iolaw/:section?" :paramsDesc="['Section ID, can be found in the URL. For example, the Section ID of URL `http://iolaw.cssn.cn/zxzp/` is `zxzp`. The default value is `zxzp`']"/>
|
||||
|
||||
## DBLP
|
||||
|
||||
### Keyword Search
|
||||
|
||||
<RouteEn author="ytno1" example="/dblp/knowledge%20tracing" path="/dblp/:field" :paramsDesc="['Research field']" radar="1" />
|
||||
|
||||
## gradCafe
|
||||
|
||||
### gradCafe result
|
||||
|
||||
@@ -85,6 +85,12 @@ path="/ctfhub/upcoming/:limit?"
|
||||
|
||||
</Route>
|
||||
|
||||
## DBLP
|
||||
|
||||
### 关键字搜索
|
||||
|
||||
<Route author="ytno1" example="/dblp/knowledge%20tracing" path="/dblp/:field" :paramsDesc="['研究领域']" radar="1" />
|
||||
|
||||
## gradCafe
|
||||
|
||||
### gradCafe result
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:field': ['ytno1'],
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
// 导入所需模组
|
||||
const got = require('@/utils/got'); // 自订的 got
|
||||
// const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
// 在此处编写您的逻辑
|
||||
const field = ctx.params.field;
|
||||
|
||||
// 发送 HTTP GET 请求到 API 并解构返回的数据对象
|
||||
const {
|
||||
result: {
|
||||
hits: { hit: data },
|
||||
},
|
||||
} = await got({
|
||||
method: 'get',
|
||||
url: 'https://dblp.org/search/publ/api',
|
||||
searchParams: {
|
||||
q: field,
|
||||
format: 'json',
|
||||
h: 10,
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
}).json();
|
||||
|
||||
// console.log(data);
|
||||
|
||||
// 从 API 响应中提取相关数据
|
||||
const list = data.map((item) => {
|
||||
const { info } = item;
|
||||
// console.log(info);
|
||||
const {
|
||||
authors: { author },
|
||||
title,
|
||||
venue,
|
||||
year,
|
||||
type,
|
||||
doi,
|
||||
ee,
|
||||
} = info;
|
||||
|
||||
let authorName;
|
||||
if (Array.isArray(author)) {
|
||||
authorName = author[0].text;
|
||||
} else {
|
||||
authorName = author.text;
|
||||
}
|
||||
|
||||
return {
|
||||
title,
|
||||
link: ee,
|
||||
author: `${authorName} et al.`,
|
||||
doi,
|
||||
description: `Year: ${year ?? 'unknown'}, Venue: ${venue}, Type: ${type}, Doi: ${doi}`,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
// 在此处输出您的 RSS
|
||||
// 源标题
|
||||
title: `【dblp】${field}`,
|
||||
// 源链接
|
||||
link: `https://dblp.org/search?q=${field}`,
|
||||
// 源描述
|
||||
description: `DBLP ${field} RSS`,
|
||||
// 处理后的数据,即文章列表
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'dblp.org': {
|
||||
_name: 'DBLP',
|
||||
'.': [
|
||||
{
|
||||
title: '关键字搜索',
|
||||
docs: 'https://docs.rsshub.app/study.html#dblp',
|
||||
source: ['/:field'],
|
||||
target: '/dblp/:field',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:field', require('./publication'));
|
||||
};
|
||||
Reference in New Issue
Block a user