mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-14 01:00:38 +08:00
feat: add はてな匿名ダイアリー (#3278)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -396,3 +396,9 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
### 房源
|
### 房源
|
||||||
|
|
||||||
<Route author="DIYgod" example="/ziroom/room/sh/1/2/五角场" path="/ziroom/room/:city/:iswhole/:room/:keyword" :paramsDesc="['城市, 北京 bj; 上海 sh; 深圳 sz; 杭州 hz; 南京 nj; 广州 gz; 成都 cd; 武汉 wh; 天津 tj', '是否整租', '房间数', '关键词']"/>
|
<Route author="DIYgod" example="/ziroom/room/sh/1/2/五角场" path="/ziroom/room/:city/:iswhole/:room/:keyword" :paramsDesc="['城市, 北京 bj; 上海 sh; 深圳 sz; 杭州 hz; 南京 nj; 广州 gz; 成都 cd; 武汉 wh; 天津 tj', '是否整租', '房间数', '关键词']"/>
|
||||||
|
|
||||||
|
## はてな
|
||||||
|
|
||||||
|
### はてな匿名ダイアリー - 人気記事アーカイブ
|
||||||
|
|
||||||
|
<Route author="masakichi" example="/hatena/anonymous_diary/archive" path="/hatena/anonymous_diary/archive"/>
|
||||||
|
|||||||
@@ -1848,6 +1848,9 @@ router.get('/4gamers/tag/:tag', require('./routes/4gamers/tag'));
|
|||||||
// 大麦网
|
// 大麦网
|
||||||
router.get('/damai/activity/:city/:category/:subcategory/:keyword?', require('./routes/damai/activity'));
|
router.get('/damai/activity/:city/:category/:subcategory/:keyword?', require('./routes/damai/activity'));
|
||||||
|
|
||||||
|
// はてな匿名ダイアリー
|
||||||
|
router.get('/hatena/anonymous_diary/archive', require('./routes/hatena/anonymous_diary/archive'));
|
||||||
|
|
||||||
// kaggle
|
// kaggle
|
||||||
router.get('/kaggle/discussion/:forumId/:sort?', require('./routes/kaggle/discussion'));
|
router.get('/kaggle/discussion/:forumId/:sort?', require('./routes/kaggle/discussion'));
|
||||||
|
|
||||||
|
|||||||
61
lib/routes/hatena/anonymous_diary/archive.js
Normal file
61
lib/routes/hatena/anonymous_diary/archive.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
function getPubDate(yyyyMMddhhmmss) {
|
||||||
|
const yyyy = yyyyMMddhhmmss.slice(0, 4);
|
||||||
|
const MM = yyyyMMddhhmmss.slice(4, 6);
|
||||||
|
const dd = yyyyMMddhhmmss.slice(6, 8);
|
||||||
|
const hh = yyyyMMddhhmmss.slice(8, 10);
|
||||||
|
const mm = yyyyMMddhhmmss.slice(10, 12);
|
||||||
|
const ss = yyyyMMddhhmmss.slice(12, 14);
|
||||||
|
return new Date(`${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}+0900`);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const baseURL = 'https://anond.hatelabo.jp';
|
||||||
|
|
||||||
|
const archiveIndex = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: url.resolve(baseURL, '/archive'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const latestURL = url.resolve(
|
||||||
|
baseURL,
|
||||||
|
cheerio
|
||||||
|
.load(archiveIndex.data)('.archives a')
|
||||||
|
.first()
|
||||||
|
.attr('href')
|
||||||
|
);
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: latestURL,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const list = $('.archives li');
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title').text(),
|
||||||
|
link: latestURL,
|
||||||
|
language: 'ja',
|
||||||
|
item:
|
||||||
|
list &&
|
||||||
|
list
|
||||||
|
.map((idx, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const a = item.find('a').first();
|
||||||
|
const yyyyMMddhhmmss = a.attr('href').replace('/', '');
|
||||||
|
return {
|
||||||
|
title: a.text(),
|
||||||
|
description: item
|
||||||
|
.find('blockquote p')
|
||||||
|
.first()
|
||||||
|
.text(),
|
||||||
|
link: url.resolve(baseURL, a.attr('href')),
|
||||||
|
pubDate: getPubDate(yyyyMMddhhmmss).toUTCString(),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user