feat(route): add 中华全国专利代理师协会 (#14197)
This commit is contained in:
parent
176341e95b
commit
64d87889de
|
|
@ -0,0 +1,57 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id = '1', name = '重要通知' } = ctx.params;
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
|
||||
|
||||
const rootUrl = 'http://www.acpaa.cn';
|
||||
const currentUrl = new URL(`article/taglist.jhtml?tagIds=${id}&tagname=${name}`, rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
let items = $('div.text01 ul li a[title]')
|
||||
.slice(0, limit)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.prop('title'),
|
||||
link: new URL(item.prop('href'), rootUrl).href,
|
||||
pubDate: timezone(parseDate(item.find('span[title]').prop('title')), +8),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: detailResponse } = await got(item.link);
|
||||
|
||||
const content = cheerio.load(detailResponse);
|
||||
|
||||
item.title = content('div.xhjj_head01').text();
|
||||
item.description = content('div.text01').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
const author = $('title').text().replace(/-/g, '');
|
||||
const subtitle = $('span.myTitle').text().trim();
|
||||
|
||||
ctx.state.data = {
|
||||
item: items,
|
||||
title: `${author} - ${subtitle}`,
|
||||
link: currentUrl,
|
||||
description: $('meta[property="og:description"]').prop('content'),
|
||||
language: 'zh',
|
||||
subtitle,
|
||||
author,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:id?/:name?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
'acpaa.cn': {
|
||||
_name: '中华全国专利代理师协会',
|
||||
'.': [
|
||||
{
|
||||
title: '文章',
|
||||
docs: 'https://docs.rsshub.app/routes/other#zhong-hua-quan-guo-zhuan-li-dai-li-shi-xie-hui',
|
||||
source: ['/article/taglist.jhtml'],
|
||||
target: (url) => {
|
||||
url = new URL(url);
|
||||
const id = url.searchParams.get('id');
|
||||
const name = url.searchParams.get('name');
|
||||
|
||||
return `/acpaa${id ? `/${id}${name ? `/${name}` : ''}` : ''}`;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/:id?/:name?', require('./'));
|
||||
};
|
||||
|
|
@ -1065,6 +1065,12 @@ Specify options (in the format of query string) in parameter `routeParams` param
|
|||
| short | zs | xh | xc | xhmr | xhmc | xcmr | xcmc |
|
||||
</Route>
|
||||
|
||||
## 中华全国专利代理师协会 {#zhong-hua-quan-guo-zhuan-li-dai-li-shi-xie-hui}
|
||||
|
||||
### 标签 {#zhong-hua-quan-guo-zhuan-li-dai-li-shi-xie-hui-biao-qian}
|
||||
|
||||
<Route author="nczitzk" example="/acpaa" path="/acpaa/:id?/:name?" paramsDesc={['标签 id,默认为 1,可在对应标签页 URL 中找到', '标签名称,默认为重要通知,可在对应标签页 URL 中找到']} radar="1" />
|
||||
|
||||
## はてな {#%E3%81%AF%E3%81%A6%E3%81%AA}
|
||||
|
||||
### はてな匿名ダイアリー - 人気記事アーカイブ {#%E3%81%AF%E3%81%A6%E3%81%AA-%E3%81%AF%E3%81%A6%E3%81%AA-ni-ming-%E3%83%80%E3%82%A4%E3%82%A2%E3%83%AA%E3%83%BC-ren-qi-ji-shi-%E3%82%A2%E3%83%BC%E3%82%AB%E3%82%A4%E3%83%96}
|
||||
|
|
|
|||
Loading…
Reference in New Issue