mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 23:42:40 +08:00
增加:Google Doodles (#1034)
This commit is contained in:
@@ -2059,6 +2059,8 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
|
||||
|
||||
</route>
|
||||
|
||||
<route name="Google Doodles" author="xyqfer" example="/google/doodles/zh-CN" path="/google/doodles/:language?" :paramsDesc="['语言,默认为`zh-CN`简体中文,如需其他语言值可从[Google Doodles 官网](https://www.google.com/doodles)获取']" />
|
||||
|
||||
### 果壳网
|
||||
|
||||
<route name="科学人" author="alphardex" example="/guokr/scientific" path="/guokr/scientific"/>
|
||||
|
||||
@@ -466,6 +466,7 @@ router.get('/nvidia/webdriverupdate', require('./routes/nvidia/webdriverupdate')
|
||||
|
||||
// Google
|
||||
router.get('/google/scholar/:query', require('./routes/google/scholar'));
|
||||
router.get('/google/doodles/:language?', require('./routes/google/doodles'));
|
||||
|
||||
// Awesome Pigtals
|
||||
router.get('/pigtails', require('./routes/pigtails'));
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { language = 'zh-CN' } = ctx.params;
|
||||
const current = new Date();
|
||||
const year = current.getFullYear();
|
||||
const month = current.getMonth() + 1;
|
||||
const link = `https://www.google.com/doodles?hl=${language}`;
|
||||
|
||||
const {
|
||||
data: { data },
|
||||
} = await axios({
|
||||
method: 'get',
|
||||
url: `https://www.google.com/doodles/json/${year}/${month}?hl=${language}`,
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Google Doodles',
|
||||
link,
|
||||
item:
|
||||
data &&
|
||||
data.map((item) => {
|
||||
const date = `${item.run_date_array[0]}-${item.run_date_array[1]}-${item.run_date_array[2]}`;
|
||||
|
||||
return {
|
||||
title: item.title,
|
||||
description: `<img src="https:${item.url}" referrerpolicy="no-referrer" /><br>${item.share_text}`,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
guid: item.url,
|
||||
link: `https://www.google.com/search?q=${encodeURIComponent(item.query)}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user