mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 08:10:32 +08:00
feat: 添加谷歌学术引用♥️ (#2565)
* 添加路由動漫狂|add router for (https://www.cartoonmad.com) * change carriages to lf * use prettier * add info to docs/readme.md * adding route for google scholar citation * formation * remove promise all
This commit is contained in:
@@ -99,6 +99,14 @@ pageClass: routes
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
### 谷歌学术作者引用更新
|
||||||
|
|
||||||
|
<Route author="KellyHwong" example="/google/citations/mlmE4JMAAAAJ" path="/google/citations/:id" crawlerBadge="1">
|
||||||
|
|
||||||
|
路由中的参数 id,即用户谷歌学术引用页面 url 中的 id,如 https://scholar.google.com/citations?hl=zh-CN&user=mlmE4JMAAAAJ 中 user= 后的 mlmE4JMAAAAJ。
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
### Google Doodles
|
### Google Doodles
|
||||||
|
|
||||||
<Route author="xyqfer" example="/google/doodles/zh-CN" path="/google/doodles/:language?" :paramsDesc="['语言,默认为`zh-CN`简体中文,如需其他语言值可从[Google Doodles 官网](https://www.google.com/doodles)获取']" />
|
<Route author="xyqfer" example="/google/doodles/zh-CN" path="/google/doodles/:language?" :paramsDesc="['语言,默认为`zh-CN`简体中文,如需其他语言值可从[Google Doodles 官网](https://www.google.com/doodles)获取']" />
|
||||||
|
|||||||
@@ -460,6 +460,7 @@ router.get('/fir/update/:id', require('./routes/fir/update'));
|
|||||||
router.get('/nvidia/webdriverupdate', require('./routes/nvidia/webdriverupdate'));
|
router.get('/nvidia/webdriverupdate', require('./routes/nvidia/webdriverupdate'));
|
||||||
|
|
||||||
// Google
|
// Google
|
||||||
|
router.get('/google/citations/:id', require('./routes/google/citations'));
|
||||||
router.get('/google/scholar/:query', require('./routes/google/scholar'));
|
router.get('/google/scholar/:query', require('./routes/google/scholar'));
|
||||||
router.get('/google/doodles/:language?', require('./routes/google/doodles'));
|
router.get('/google/doodles/:language?', require('./routes/google/doodles'));
|
||||||
|
|
||||||
|
|||||||
51
lib/routes/google/citations.js
Normal file
51
lib/routes/google/citations.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const id = ctx.params.id;
|
||||||
|
let description = `Google Scholar Citation Monitor: ${id};`;
|
||||||
|
const BASE_URL = `https://scholar.google.com`;
|
||||||
|
const url = `https://scholar.google.com/citations?user=${id}`;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const profile = $('#gsc_prf .gsc_prf_il')
|
||||||
|
.eq(0)
|
||||||
|
.text();
|
||||||
|
const homePage = $('#gsc_prf_ivh a').attr('href');
|
||||||
|
const name = $('#gsc_prf_in').text();
|
||||||
|
description += `name: ${name}; profile: ${profile}; homePage: ${homePage}`;
|
||||||
|
|
||||||
|
const list = $('#gsc_a_b .gsc_a_tr').get();
|
||||||
|
|
||||||
|
const out = list.map((item) => {
|
||||||
|
const $ = cheerio.load(item);
|
||||||
|
|
||||||
|
let itemUrl = $('.gsc_a_t a').attr('data-href');
|
||||||
|
itemUrl = BASE_URL + itemUrl;
|
||||||
|
|
||||||
|
const author = $('.gsc_a_t div')
|
||||||
|
.eq(0)
|
||||||
|
.text();
|
||||||
|
const publication = $('.gsc_a_t div')
|
||||||
|
.eq(1)
|
||||||
|
.text();
|
||||||
|
return {
|
||||||
|
title: $('.gsc_a_t a').text(),
|
||||||
|
description: `Author: ${author}; Publication: ${publication}`,
|
||||||
|
link: itemUrl,
|
||||||
|
guid: itemUrl,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `Google Scholar Citation Monitor: ${id}`,
|
||||||
|
link: url,
|
||||||
|
description: description,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user