mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 05:36:08 +08:00
feat(route): add Whoscall (#8478)
* feat(route): add Whoscall * fix: add docs
This commit is contained in:
27
docs/blog.md
27
docs/blog.md
@@ -90,6 +90,33 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="CitrusIce" example="/phrack" path="/phrack" />
|
<Route author="CitrusIce" example="/phrack" path="/phrack" />
|
||||||
|
|
||||||
|
## Whoscall
|
||||||
|
|
||||||
|
### 最新文章
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/whoscall" path="/whoscall"/>
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
### 分類
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/whoscall/categories/5-Whoscall 百科" path="/whoscall/categories/:category?" :paramsDesc="['分类,见下表,可在对应分類页 URL 中找到,默认为最新文章']">
|
||||||
|
|
||||||
|
| News | Whoscall 百科 | 防詐小學堂 | Whoscall 日常 |
|
||||||
|
| ------ | --------------- | -------------- | --------------- |
|
||||||
|
| 1-News | 5-Whoscall 百科 | 4 - 防詐小學堂 | 6-Whoscall 日常 |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
### 標籤
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/whoscall/tags/whoscall小百科" path="/whoscall/tags/:tag?" :paramsDesc="['標籤,见下表,可在对应標籤页 URL 中找到,默认为最新文章']">
|
||||||
|
|
||||||
|
| 防疫也防詐 | 防詐專家 | 來電辨識 | whoscall 日常 |
|
||||||
|
| ---------- | -------- | -------- | ------------- |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## WordPress
|
## WordPress
|
||||||
|
|
||||||
<Route author="Lonor" example="/blogs/wordpress/lawrence.code.blog" path="/blogs/wordpress/:domain/:https?" :paramsDesc="['WordPress 博客域名', '默认 https 协议。填写 `http`或`https`']"/>
|
<Route author="Lonor" example="/blogs/wordpress/lawrence.code.blog" path="/blogs/wordpress/:domain/:https?" :paramsDesc="['WordPress 博客域名', '默认 https 协议。填写 `http`或`https`']"/>
|
||||||
|
|||||||
55
lib/v2/whoscall/index.js
Normal file
55
lib/v2/whoscall/index.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const id = ctx.params.id ?? '';
|
||||||
|
const what = ctx.params.what ?? '';
|
||||||
|
|
||||||
|
const rootUrl = 'https://whoscall.com';
|
||||||
|
const currentUrl = `${rootUrl}/zh-hant/blog/${id ? `${what}/${id}` : 'articles'}`;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: currentUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const list = $('.post-card__title a')
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: item.text(),
|
||||||
|
link: `${rootUrl}${item.attr('href')}`,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
});
|
||||||
|
|
||||||
|
const content = cheerio.load(detailResponse.data);
|
||||||
|
|
||||||
|
item.description = content('.blog-article__body').html();
|
||||||
|
item.pubDate = parseDate(detailResponse.data.match(/"datePublished":"(.*)","dateModified"/)[1]);
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title')
|
||||||
|
.text()
|
||||||
|
.replace(/ - 第\d+頁/, ''),
|
||||||
|
link: currentUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
5
lib/v2/whoscall/maintainer.js
Normal file
5
lib/v2/whoscall/maintainer.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/': ['nczitzk'],
|
||||||
|
'/tags/:tag?': ['nczitzk'],
|
||||||
|
'/categories/:category?': ['nczitzk'],
|
||||||
|
};
|
||||||
25
lib/v2/whoscall/radar.js
Normal file
25
lib/v2/whoscall/radar.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
module.exports = {
|
||||||
|
'whoscall.com': {
|
||||||
|
_name: 'Whoscall',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '最新文章',
|
||||||
|
docs: 'https://docs.rsshub.app/blog.html#whoscall-zui-xin-wen-zhang',
|
||||||
|
source: ['/zh-hant/blog/articles', '/'],
|
||||||
|
target: '/whoscall',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '分類',
|
||||||
|
docs: 'https://docs.rsshub.app/blog.html#whoscall-fen-lei',
|
||||||
|
source: ['/zh-hant/blog/categories/:category', '/'],
|
||||||
|
target: '/whoscall/categories/:category?',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '標籤',
|
||||||
|
docs: 'https://docs.rsshub.app/blog.html#whoscall-biao-qian',
|
||||||
|
source: ['/zh-hant/blog/tags/:tag', '/'],
|
||||||
|
target: '/whoscall/tags/:tag?',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/whoscall/router.js
Normal file
3
lib/v2/whoscall/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/:what?/:id?', require('./index'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user