mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
feat: 添加 clickme (#3440)
This commit is contained in:
@@ -31,6 +31,12 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="lalxyy" example="/checkee/2019-03" path="/checkee/:month" :paramsDesc="['签证被 check 的年份-月份,如 2019-03']" />
|
<Route author="lalxyy" example="/checkee/2019-03" path="/checkee/:month" :paramsDesc="['签证被 check 的年份-月份,如 2019-03']" />
|
||||||
|
|
||||||
|
## ClickMe
|
||||||
|
|
||||||
|
### 文章
|
||||||
|
|
||||||
|
<Route author="hoilc" example="/clickme/default/category/beauty" path="/clickme/:site/:grouping/:name" :paramsDesc="['站点, `default`为普通站, `r18`为成人站, 其它值默认为普通站','分组方式, `category`为分类, `tag`为标签, 其他值默认为分类','分类名或标签名, 分类名为英文, 可以在分类 URL 中找到']" />
|
||||||
|
|
||||||
## DHL
|
## DHL
|
||||||
|
|
||||||
### DHL 国际快递包裹追踪
|
### DHL 国际快递包裹追踪
|
||||||
|
|||||||
@@ -1935,6 +1935,9 @@ router.get('/gov/cnca/hydt', require('./routes/gov/cnca/hydt'));
|
|||||||
|
|
||||||
router.get('/gov/cnca/zxtz', require('./routes/gov/cnca/zxtz'));
|
router.get('/gov/cnca/zxtz', require('./routes/gov/cnca/zxtz'));
|
||||||
|
|
||||||
|
// clickme
|
||||||
|
router.get('/clickme/:site/:grouping/:name', require('./routes/clickme'));
|
||||||
|
|
||||||
// 文汇报
|
// 文汇报
|
||||||
router.get('/whb/:category', require('./routes/whb/zhuzhan'));
|
router.get('/whb/:category', require('./routes/whb/zhuzhan'));
|
||||||
|
|
||||||
|
|||||||
70
lib/routes/clickme/index.js
Normal file
70
lib/routes/clickme/index.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const site = ctx.params.site === 'r18' ? 'r18' : '';
|
||||||
|
const grouping = ctx.params.grouping === 'tag' ? 'tag' : 'category';
|
||||||
|
const name = ctx.params.name;
|
||||||
|
|
||||||
|
const url = `https://${site ? 'r18.' : ''}clickme.net/${grouping.slice(0, 1)}/${encodeURIComponent(name)}`;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'post',
|
||||||
|
url: 'https://api.clickme.net/article/list?key=clickme',
|
||||||
|
headers: {
|
||||||
|
Referer: url,
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
body: `articleType=${site ? 'r18' : 'article'}&subtype=${grouping}&subtypeSlug=${encodeURIComponent(name)}&device=&limit=10&page=1`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const category_name = name === 'new' ? '最新' : response.data.data.items[0].categoryName[0].name;
|
||||||
|
const displayed_name = grouping === 'tag' ? name : category_name;
|
||||||
|
|
||||||
|
const list = response.data.data.items;
|
||||||
|
|
||||||
|
const parseContent = (htmlString) => {
|
||||||
|
const $ = cheerio.load(htmlString);
|
||||||
|
const content = $('.article-detail-content');
|
||||||
|
return {
|
||||||
|
description: content.html(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const link = item.url;
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const rssitem = {
|
||||||
|
title: item.title,
|
||||||
|
link: link,
|
||||||
|
author: item.userNick,
|
||||||
|
pubDate: new Date(item.date * 1000),
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await got.get(link);
|
||||||
|
const result = parseContent(response.data);
|
||||||
|
if (!result) {
|
||||||
|
return Promise.resolve('');
|
||||||
|
}
|
||||||
|
rssitem.description = result.description;
|
||||||
|
} catch (err) {
|
||||||
|
return Promise.resolve('');
|
||||||
|
}
|
||||||
|
ctx.cache.set(link, JSON.stringify(rssitem));
|
||||||
|
return Promise.resolve(rssitem);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `ClickMe ${site ? 'R18 ' : ''}- ${displayed_name}`,
|
||||||
|
link: url,
|
||||||
|
item: out.filter((item) => item !== ''),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user