forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): 新增博客道宣的窝 (DIYgod#17890)
* 尝试 * /daoxuan * 修改example * Update lib/routes/daoxuan/rss.ts ---------
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '道宣的窝', | ||
url: 'daoxuan.cc', | ||
lang: 'zh-CN', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/', | ||
categories: ['blog'], | ||
example: '/daoxuan', | ||
radar: [ | ||
{ | ||
source: ['daoxuan.cc/'], | ||
}, | ||
], | ||
name: '推荐阅读文章', | ||
maintainers: ['dx2331lxz'], | ||
url: 'daoxuan.cc/', | ||
handler, | ||
}; | ||
|
||
async function handler() { | ||
const url = 'https://daoxuan.cc/'; | ||
const response = await got({ method: 'get', url }); | ||
const $ = load(response.data); | ||
const items = $('div.recent-post-item') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
const a = item.find('a.article-title').first(); | ||
const timeElement = item.find('time').first(); | ||
return { | ||
title: a.attr('title'), | ||
link: `https://daoxuan.cc${a.attr('href')}`, | ||
pubDate: parseDate(timeElement.attr('datetime')), | ||
description: a.attr('title'), | ||
}; | ||
}); | ||
return { | ||
title: '道宣的窝', | ||
link: url, | ||
item: items, | ||
}; | ||
} |