mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 10:38:03 +08:00
feat(route): add tokeninsight (#8725)
* feat: add tokeninsight's bulletin * feat: add tokeninsight's report and blog * 🔧 Add Limit for tokeninsight * refactor: migrate to v2 * fix: maintainer path Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,28 @@ pageClass: routes
|
||||
|
||||
<RouteEn author="HenryQW" example="/finviz/news/AAPL" path="/finviz/news/:ticker" :paramsDesc="['The stock ticker']"/>
|
||||
|
||||
## TokenInsight
|
||||
|
||||
### Blogs
|
||||
|
||||
<RouteEn author="fuergaosi233" example="/tokeninsight/blog/en" path="/tokeninsight/blog/:lang?" :paramsDesc="['Language, see below, Chinese by default']" />
|
||||
|
||||
### Latest
|
||||
|
||||
<RouteEn author="fuergaosi233" example="/tokeninsight/bulletin/en" path="/tokeninsight/bulletin/:lang?" :paramsDesc="['Language, see below, Chinese by default']" />
|
||||
|
||||
### Research
|
||||
|
||||
<RouteEn author="fuergaosi233" example="/tokeninsight/report/en" path="/tokeninsight/report/:lang?" :paramsDesc="['Language, see below, Chinese by default']">
|
||||
|
||||
Language:
|
||||
|
||||
| Chinese | English |
|
||||
| ------- | ------- |
|
||||
| zh | en |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## World Economic Forum
|
||||
|
||||
### Report
|
||||
|
||||
@@ -38,6 +38,28 @@ pageClass: routes
|
||||
|
||||
<Route author="HenryQW" example="/finviz/news/AAPL" path="/finviz/news/:ticker" :paramsDesc="['股票代码']"/>
|
||||
|
||||
## TokenInsight
|
||||
|
||||
### 博客
|
||||
|
||||
<Route author="fuergaosi233" example="/tokeninsight/blog" path="/tokeninsight/blog/:lang?" :paramsDesc="['语言,见下表,默认为简体中文']" />
|
||||
|
||||
### 快讯
|
||||
|
||||
<Route author="fuergaosi233" example="/tokeninsight/bulletin" path="/tokeninsight/bulletin/:lang?" :paramsDesc="['语言,见下表,默认为简体中文']" />
|
||||
|
||||
### 报告
|
||||
|
||||
<Route author="fuergaosi233" example="/tokeninsight/report" path="/tokeninsight/report/:lang?" :paramsDesc="['语言,见下表,默认为简体中文']">
|
||||
|
||||
语言
|
||||
|
||||
| 中文 | 英文 |
|
||||
| -- | -- |
|
||||
| zh | en |
|
||||
|
||||
</Route>
|
||||
|
||||
## WEEX 华尔街见闻旗下全球投资线上品牌
|
||||
|
||||
### 资讯
|
||||
|
||||
52
lib/v2/tokeninsight/blog.js
Normal file
52
lib/v2/tokeninsight/blog.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const baseURL = 'https://www.tokeninsight.com/';
|
||||
const title = 'TokenInsight';
|
||||
const link = 'https://www.tokeninsight.com/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const lang = ctx.params.lang ?? 'zh';
|
||||
|
||||
const getBlogs = async () => {
|
||||
const url = `${baseURL}api/user/search/getAllList`;
|
||||
const response = (
|
||||
await got.post(url, {
|
||||
form: {
|
||||
isRecommend: 2,
|
||||
language: lang === 'zh' ? 'cn' : lang,
|
||||
},
|
||||
})
|
||||
).data;
|
||||
return response.data.blogsList;
|
||||
};
|
||||
|
||||
const getBlogInfomation = async (blog) => {
|
||||
const { publishDate, title, id } = blog;
|
||||
const blogUrl = `${baseURL}${lang}/blogs/${id}`;
|
||||
const description = await ctx.cache.tryGet(blogUrl, async () => {
|
||||
const res = await got(blogUrl);
|
||||
const $ = cheerio.load(res.data);
|
||||
const description = $('.detail_html_box').html();
|
||||
return description;
|
||||
});
|
||||
return {
|
||||
// 文章标题
|
||||
title,
|
||||
// 文章正文
|
||||
description,
|
||||
// 文章发布时间
|
||||
pubDate: parseDate(publishDate),
|
||||
// 文章链接
|
||||
link: blogUrl,
|
||||
};
|
||||
};
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 30;
|
||||
const blogs = (await getBlogs()).slice(0, limit);
|
||||
const list = await Promise.all(blogs.map(getBlogInfomation));
|
||||
ctx.state.data = {
|
||||
title: `${lang === 'zh' ? '博客' : 'Blogs'} | ${title}`,
|
||||
link: `${link}${lang}/blogs`,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
44
lib/v2/tokeninsight/bulletin.js
Normal file
44
lib/v2/tokeninsight/bulletin.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const baseURL = 'https://www.tokeninsight.com/';
|
||||
const title = 'TokenInsight';
|
||||
const link = 'https://www.tokeninsight.com/';
|
||||
const get_articles = async () => {
|
||||
const url = `${baseURL}api/bulletin/selectBulletinList`;
|
||||
const response = (await got.get(url)).data;
|
||||
const { data } = response;
|
||||
return data;
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const lang = ctx.params.lang ?? 'zh';
|
||||
|
||||
const get_article_info = async (article) => {
|
||||
const { updateDate, titleEn, id, title } = article;
|
||||
const articleUrl = `${baseURL}${lang}/latest/${id}`;
|
||||
const description = await ctx.cache.tryGet(articleUrl, async () => {
|
||||
const res = await got(articleUrl);
|
||||
const $ = cheerio.load(res.data);
|
||||
return $('.detail_html_box').html();
|
||||
});
|
||||
return {
|
||||
// 文章标题
|
||||
title: lang === 'zh' ? title : titleEn,
|
||||
// 文章正文
|
||||
description,
|
||||
// 文章发布时间
|
||||
pubDate: parseDate(updateDate),
|
||||
// 文章链接
|
||||
link: articleUrl,
|
||||
};
|
||||
};
|
||||
|
||||
const articles = await get_articles();
|
||||
const list = await Promise.all(articles.map(get_article_info));
|
||||
ctx.state.data = {
|
||||
title: `${lang === 'zh' ? '快讯' : 'Latest'} | ${title}`,
|
||||
link: `${link}${lang}/latest`,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
5
lib/v2/tokeninsight/maintainer.js
Normal file
5
lib/v2/tokeninsight/maintainer.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
'/blog/:lang?': ['fuergaosi233'],
|
||||
'/bulletin:lang?': ['fuergaosi233'],
|
||||
'/report:lang?': ['fuergaosi233'],
|
||||
};
|
||||
25
lib/v2/tokeninsight/radar.js
Normal file
25
lib/v2/tokeninsight/radar.js
Normal file
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
'tokeninsight.com': {
|
||||
_name: 'TokenInsight',
|
||||
'.': [
|
||||
{
|
||||
title: '博客',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#tokeninsight',
|
||||
source: ['/:lang/blogs'],
|
||||
target: '/tokeninsight/blog/:lang',
|
||||
},
|
||||
{
|
||||
title: '快讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#tokeninsight',
|
||||
source: ['/:lang/latest'],
|
||||
target: '/tokeninsight/bulletin/:lang',
|
||||
},
|
||||
{
|
||||
title: '报告',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#tokeninsight',
|
||||
source: ['/:lang/report'],
|
||||
target: '/tokeninsight/report/:lang',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
52
lib/v2/tokeninsight/report.js
Normal file
52
lib/v2/tokeninsight/report.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const baseURL = 'https://www.tokeninsight.com/';
|
||||
const title = 'TokenInsight';
|
||||
const link = 'https://www.tokeninsight.com/';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const lang = ctx.params.lang ?? 'zh';
|
||||
|
||||
const getReports = async () => {
|
||||
const url = `${baseURL}api/user/search/getAllList`;
|
||||
const response = (
|
||||
await got.post(url, {
|
||||
form: {
|
||||
isRecommend: 2,
|
||||
language: lang === 'zh' ? 'cn' : lang,
|
||||
},
|
||||
})
|
||||
).data;
|
||||
return response.data.reportList;
|
||||
};
|
||||
|
||||
const getReportInfomation = async (report) => {
|
||||
const { publishDate, title, id } = report;
|
||||
const reportUrl = `${baseURL}${lang}/report/${id}`;
|
||||
const description = await ctx.cache.tryGet(reportUrl, async () => {
|
||||
const res = await got(reportUrl);
|
||||
const $ = cheerio.load(res.data);
|
||||
const description = $('.detail_html_box').html();
|
||||
return description;
|
||||
});
|
||||
return {
|
||||
// 文章标题
|
||||
title,
|
||||
// 文章正文
|
||||
description,
|
||||
// 文章发布时间
|
||||
pubDate: parseDate(publishDate),
|
||||
// 文章链接
|
||||
link: reportUrl,
|
||||
};
|
||||
};
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 30;
|
||||
const reports = (await getReports()).slice(0, limit);
|
||||
const list = await Promise.all(reports.map(getReportInfomation));
|
||||
ctx.state.data = {
|
||||
title: `${lang === 'zh' ? '报告' : 'Research'} | ${title}`,
|
||||
link: `${link}${lang}/report`,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
5
lib/v2/tokeninsight/router.js
Normal file
5
lib/v2/tokeninsight/router.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/blog/:lang?', require('./blog.js'));
|
||||
router.get('/bulletin/:lang?', require('./bulletin.js'));
|
||||
router.get('/report/:lang?', require('./report.js'));
|
||||
};
|
||||
Reference in New Issue
Block a user