Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<script>
|
||||
alert('The documentation has been changed to docs.rsshub.app and will be automatically redirected to the new documentation page.');
|
||||
window.location.href = 'https://docs.rsshub.app';
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
rsshub.js.org
|
||||
@@ -0,0 +1,4 @@
|
||||
<script>
|
||||
alert('The documentation has been changed to docs.rsshub.app and will be automatically redirected to the new documentation page.');
|
||||
window.location.href = 'https://docs.rsshub.app';
|
||||
</script>
|
||||
@@ -1,15 +1,11 @@
|
||||
import { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got, { type Response } from '@/utils/got';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const baseUrl = 'https://www.cast.org.cn';
|
||||
|
||||
interface ResponseData<T> extends Response {
|
||||
data: T;
|
||||
}
|
||||
|
||||
async function parsePage(html: string) {
|
||||
return await Promise.all(
|
||||
load(html)('li')
|
||||
@@ -27,7 +23,7 @@ async function parsePage(html: string) {
|
||||
articleUrl = `${baseUrl}${title.attr('href')}`;
|
||||
|
||||
return cache.tryGet(articleUrl, async () => {
|
||||
const res = (await got.get(articleUrl!)) as ResponseData<string>;
|
||||
const res = await got.get<string>(articleUrl!);
|
||||
const article = load(res.data);
|
||||
const pubDate = timezone(parseDate(article('meta[name=PubDate]').attr('content')!, 'YYYY-MM-DD HH:mm'), +8);
|
||||
|
||||
@@ -55,6 +51,10 @@ export const route: Route = {
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: {
|
||||
source: ['cast.org.cn/:column/:subColumn/:category/index.html', 'cast.org.cn/:column/:subColumn/index.html'],
|
||||
target: '/cast/:column/:subColumn/:category?',
|
||||
},
|
||||
name: '通用',
|
||||
maintainers: ['KarasuShin', 'TonyRL'],
|
||||
handler,
|
||||
@@ -80,7 +80,7 @@ async function handler(ctx) {
|
||||
if (category) {
|
||||
link += `/${category}/index.html`;
|
||||
}
|
||||
const { data: indexData } = (await got.get(link)) as ResponseData<string>;
|
||||
const { data: indexData } = await got.get<string>(link);
|
||||
|
||||
const $ = load(indexData);
|
||||
|
||||
@@ -95,9 +95,9 @@ async function handler(ctx) {
|
||||
const queryData = JSON.parse(buildUnitScript.attr('querydata')?.replace(/'/g, '"') ?? '{}');
|
||||
queryData.paramJson = `{"pageNo":1,"pageSize":${limit}}`;
|
||||
|
||||
const { data } = (await got.get(queryUrl, {
|
||||
const { data } = await got.get<{ data: { html: string } }>(queryUrl, {
|
||||
searchParams: new URLSearchParams(queryData),
|
||||
})) as ResponseData<{ data: { html: string } }>;
|
||||
});
|
||||
|
||||
items = await parsePage(data.data.html);
|
||||
}
|
||||
|
||||
@@ -151,12 +151,9 @@ async function handler(ctx) {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title,
|
||||
link: `https://weibo.com`,
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title,
|
||||
link: `https://weibo.com`,
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,13 +108,10 @@ async function handler(ctx) {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: groupName,
|
||||
link: `https://weibo.com/mygroups?gid=${gid}`,
|
||||
description: '微博自定义分组',
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: groupName,
|
||||
link: `https://weibo.com/mygroups?gid=${gid}`,
|
||||
description: '微博自定义分组',
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
+16
-18
@@ -48,22 +48,20 @@ async function handler(ctx) {
|
||||
);
|
||||
|
||||
const routeParams = querystring.parse(ctx.req.param('routeParams'));
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `又有人在微博提到${keyword}了`,
|
||||
link: `http://s.weibo.com/weibo/${encodeURIComponent(keyword)}&b=1&nodup=1`,
|
||||
description: `又有人在微博提到${keyword}了`,
|
||||
item: data.map((item) => {
|
||||
item.mblog.created_at = timezone(item.mblog.created_at, +8);
|
||||
if (item.mblog.retweeted_status && item.mblog.retweeted_status.created_at) {
|
||||
item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, +8);
|
||||
}
|
||||
return weiboUtils.formatExtended(ctx, item.mblog, undefined, {
|
||||
showAuthorInTitle: fallback(undefined, queryToBoolean(routeParams.showAuthorInTitle), true),
|
||||
showAuthorInDesc: fallback(undefined, queryToBoolean(routeParams.showAuthorInDesc), true),
|
||||
});
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `又有人在微博提到${keyword}了`,
|
||||
link: `http://s.weibo.com/weibo/${encodeURIComponent(keyword)}&b=1&nodup=1`,
|
||||
description: `又有人在微博提到${keyword}了`,
|
||||
item: data.map((item) => {
|
||||
item.mblog.created_at = timezone(item.mblog.created_at, +8);
|
||||
if (item.mblog.retweeted_status && item.mblog.retweeted_status.created_at) {
|
||||
item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, +8);
|
||||
}
|
||||
return weiboUtils.formatExtended(ctx, item.mblog, undefined, {
|
||||
showAuthorInTitle: fallback(undefined, queryToBoolean(routeParams.showAuthorInTitle), true),
|
||||
showAuthorInDesc: fallback(undefined, queryToBoolean(routeParams.showAuthorInDesc), true),
|
||||
});
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,21 +27,18 @@ export const route: Route = {
|
||||
async function handler(ctx) {
|
||||
const userid = ctx.req.param('userid');
|
||||
const link = `https://oasis.weibo.cn/v1/h5/share?uid=${userid}`;
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax(
|
||||
await buildData({
|
||||
link,
|
||||
url: link,
|
||||
title: `$('.name-main').text().trim() + ' - 用户 - 绿洲'`,
|
||||
description: `$('.desc').text().trim()`,
|
||||
item: {
|
||||
item: '.container .status-item',
|
||||
title: `$('.status-item-title').clone().children().remove().end().text()`,
|
||||
description: `$('.status-item-title').clone().children().remove().end().text() + '<br>' + $('.status-img').html()`,
|
||||
link: `'https://oasis.weibo.cn/v1/h5/share?sid=' + $('.status-item-title').parent().data('id')`,
|
||||
},
|
||||
})
|
||||
)
|
||||
return weiboUtils.sinaimgTvax(
|
||||
await buildData({
|
||||
link,
|
||||
url: link,
|
||||
title: `$('.name-main').text().trim() + ' - 用户 - 绿洲'`,
|
||||
description: `$('.desc').text().trim()`,
|
||||
item: {
|
||||
item: '.container .status-item',
|
||||
title: `$('.status-item-title').clone().children().remove().end().text()`,
|
||||
description: `$('.status-item-title').clone().children().remove().end().text() + '<br>' + $('.status-img').html()`,
|
||||
link: `'https://oasis.weibo.cn/v1/h5/share?sid=' + $('.status-item-title').parent().data('id')`,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,13 +76,10 @@ async function handler(ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `微博超话 - ${containerData.pageInfo.page_title}`,
|
||||
link: `https://weibo.com/p/${id}/super_index`,
|
||||
description: `#${containerData.pageInfo.page_title}# 的超话`,
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `微博超话 - ${containerData.pageInfo.page_title}`,
|
||||
link: `https://weibo.com/p/${id}/super_index`,
|
||||
description: `#${containerData.pageInfo.page_title}# 的超话`,
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -151,16 +151,13 @@ async function handler(ctx) {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `个人微博时间线--${name}`,
|
||||
link: `http://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItem,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `个人微博时间线--${name}`,
|
||||
link: `http://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItem,
|
||||
});
|
||||
} else if (uid === '0' || ctx.req.query()) {
|
||||
const { app_key = '', redirect_url = ctx.req.origin + '/weibo/timeline/0', app_secret = '' } = config.weibo;
|
||||
|
||||
|
||||
@@ -169,14 +169,11 @@ async function handler(ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `${name}的微博`,
|
||||
link: `https://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `${name}的微博`,
|
||||
link: `https://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ const weiboUtils = {
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/"https:\/\/weibo\.cn\/sinaurl.*?[&?]u=(http.*?)"/g, (match, p1) => `"${decodeURIComponent(p1)}"`);
|
||||
|
||||
// 处理图片的链接
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/<a\s+href="https?:\/\/.+\.(jpg|png|gif)"/g, (match) => `${match} data-rsshub-image="href"`);
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/<a\s+href="https?:\/\/[^"]+\.(jpg|png|gif)"/g, (match) => `${match} data-rsshub-image="href"`);
|
||||
|
||||
let html = htmlNewLineUnreplaced.replaceAll('\n', '<br>');
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ Language
|
||||
|
||||
### 通用
|
||||
|
||||
<Route namespace="cast" data={{"path":"/:column/:subColumn/:category?","categories":["government"],"example":"/cast/xw/tzgg/ZH","parameters":{"column":"栏目编号,见下表","subColumn":"二级栏目编号","category":"分类"},"features":{"requireConfig":false,"requirePuppeteer":false,"antiCrawler":false,"supportBT":false,"supportPodcast":false,"supportScihub":false},"name":"通用","maintainers":["KarasuShin","TonyRL"],"description":":::tip\n 在路由末尾处加上 `?limit=限制获取数目` 来限制获取条目数量,默认值为`10`\n :::\n\n | 分类 | 编码 |\n | -------- | ---- |\n | 全景科协 | qjkx |\n | 智库 | zk |\n | 学术 | xs |\n | 科普 | kp |\n | 党建 | dj |\n | 数据 | sj |\n | 新闻 | xw |","location":"index.ts"}} />
|
||||
<Route namespace="cast" data={{"path":"/:column/:subColumn/:category?","categories":["government"],"example":"/cast/xw/tzgg/ZH","parameters":{"column":"栏目编号,见下表","subColumn":"二级栏目编号","category":"分类"},"features":{"requireConfig":false,"requirePuppeteer":false,"antiCrawler":false,"supportBT":false,"supportPodcast":false,"supportScihub":false},"radar":{"source":["cast.org.cn/:column/:subColumn/:category/index.html","cast.org.cn/:column/:subColumn/index.html"],"target":"/cast/:column/:subColumn/:category?"},"name":"通用","maintainers":["KarasuShin","TonyRL"],"description":":::tip\n 在路由末尾处加上 `?limit=限制获取数目` 来限制获取条目数量,默认值为`10`\n :::\n\n | 分类 | 编码 |\n | -------- | ---- |\n | 全景科协 | qjkx |\n | 智库 | zk |\n | 学术 | xs |\n | 科普 | kp |\n | 党建 | dj |\n | 数据 | sj |\n | 新闻 | xw |","location":"index.ts"}} />
|
||||
|
||||
:::tip
|
||||
在路由末尾处加上 `?limit=限制获取数目` 来限制获取条目数量,默认值为`10`
|
||||
|
||||
Reference in New Issue
Block a user