fix(route): 教育部路由新增教育要闻分类,修复部分文章标题取值;优化雪球路由,对于讨论帖直接获取完整内容 (#9556)
* 雪球的讨论帖可以直接从text字段中取到完整内容,长文帖只有description字段有值,获取逻辑不变 * 教育部路由增加“教育要闻”栏目类型获取,同时修复教育部文章title获取不到的问题 * 补充教育部路由增加教育要闻栏目类型的文档 * refactor: migrate to v2 * fix: legacy url.resolve * 修复雪球返回完整讨论帖时遗漏了转发内容的问题 * 移除重复的key Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
+3
-3
@@ -933,9 +933,9 @@ pageClass: routes
|
||||
|
||||
<Route author="Crawler995" example="/gov/moe/policy_anal" path="/gov/moe/:type" :paramsDesc="['分类名']">
|
||||
|
||||
| 政策解读 | 最新文件 | 公告公示 | 教育部简报 |
|
||||
| :---------: | :---------: | :----: | :---------------: |
|
||||
| policy_anal | newest_file | notice | edu_ministry_news |
|
||||
| 政策解读 | 最新文件 | 公告公示 | 教育部简报 | 教育要闻 |
|
||||
| :---------: | :---------: | :----: | :---------------: | :---------------: |
|
||||
| policy_anal | newest_file | notice | edu_ministry_news | edu_focus_news |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
+2
-2
@@ -1220,8 +1220,8 @@ router.get('/gov/ndrc/xwdt/:caty?', lazyloadRouteHandler('./routes/gov/ndrc/xwdt
|
||||
// 中华人民共和国-海关总署
|
||||
router.get('/gov/customs/list/:gchannel', lazyloadRouteHandler('./routes/gov/customs/list'));
|
||||
|
||||
// 中华人民共和国教育部
|
||||
router.get('/gov/moe/:type', lazyloadRouteHandler('./routes/gov/moe/moe'));
|
||||
// 中华人民共和国教育部 migrated to v2
|
||||
// router.get('/gov/moe/:type', lazyloadRouteHandler('./routes/gov/moe/moe'));
|
||||
|
||||
// 中华人民共和国外交部
|
||||
// router.get('/gov/fmprc/fyrbt', lazyloadRouteHandler('./routes/gov/fmprc/fyrbt'));
|
||||
|
||||
+14
-11
@@ -1,24 +1,27 @@
|
||||
module.exports = {
|
||||
'/anhui/kjt/:path?': ['nczitzk'],
|
||||
'/beijing/kw/:channel': ['Fatpandac'],
|
||||
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
|
||||
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
|
||||
'/shanghai/rsj/ksxm': ['Fatpandac'],
|
||||
'/fmprc/:category?': ['nicolaszf', 'nczitzk'],
|
||||
'/guangdong/tqyb/tfxtq': ['Fatpandac'],
|
||||
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
|
||||
'/huizhou/zwgk/:category?': ['Fatpandac'],
|
||||
'/sichuan/deyang/govpulicinfo/:countyName': ['zytomorrow'],
|
||||
'/mee/ywdt?': ['liuxsdev'],
|
||||
'/mfa/wjdt/:category?': ['nczitzk'],
|
||||
'/miit/wjfb/:ministry': ['Fatpandac'],
|
||||
'/miit/yjzj': ['Fatpandac'],
|
||||
'/miit/zcwj': ['Yoge-Code'],
|
||||
'/miit/wjgs': ['Yoge-Code'],
|
||||
'/miit/zcjd': ['Yoge-Code'],
|
||||
'/mee/ywdt?': ['liuxsdev'],
|
||||
'/moe/:type': ['Crawler995'],
|
||||
'/nrta/news/:category?': ['yuxinliu-alex'],
|
||||
'/pbc/goutongjiaoliu': ['nczitzk'],
|
||||
'/pbc/gzlw': ['Fatpandac'],
|
||||
'/pbc/tradeAnnouncement': ['nczitzk'],
|
||||
'/pbc/zcyj': ['Fatpandac'],
|
||||
'/pbc/gzlw': ['Fatpandac'],
|
||||
|
||||
'/anhui/kjt/:path?': ['nczitzk'],
|
||||
'/beijing/kw/:channel': ['Fatpandac'],
|
||||
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
|
||||
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
|
||||
'/shanghai/rsj/ksxm': ['Fatpandac'],
|
||||
'/shanghai/wsjkw/yqtb': ['zcf0508'],
|
||||
'/guangdong/tqyb/tfxtq': ['Fatpandac'],
|
||||
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
|
||||
'/huizhou/zwgk/:category?': ['Fatpandac'],
|
||||
'/sichuan/deyang/govpulicinfo/:countyName': ['zytomorrow'],
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const logger = require('@/utils/logger');
|
||||
const liburl = require('url');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const moeUrl = 'http://www.moe.gov.cn/';
|
||||
const typesIdMap = [
|
||||
@@ -9,6 +9,7 @@ const typesIdMap = [
|
||||
{ type: 'newest_file', id: 'nine_con1', name: '最新文件' },
|
||||
{ type: 'notice', id: 'nine_con2', name: '公告公示' },
|
||||
{ type: 'edu_ministry_news', id: 'nine_con3', name: '教育部简报' },
|
||||
{ type: 'edu_focus_news', id: 'eight_con2 .TRS_Editor', name: '教育要闻' },
|
||||
];
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
@@ -28,11 +29,7 @@ module.exports = async (ctx) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: moeUrl,
|
||||
Host: 'www.moe.gov.cn',
|
||||
});
|
||||
const response = await got(moeUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const newsLis = $('div#' + id + '>ul>li');
|
||||
@@ -46,15 +43,11 @@ module.exports = async (ctx) => {
|
||||
item = $(item);
|
||||
|
||||
const firstA = item.find('a');
|
||||
const itemUrl = liburl.resolve(moeUrl, firstA.attr('href'));
|
||||
const itemUrl = new URL(firstA.attr('href'), moeUrl).href;
|
||||
|
||||
const infos = await ctx.cache.tryGet(itemUrl, async () => {
|
||||
const res = {};
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: itemUrl,
|
||||
Host: 'www.moe.gov.cn',
|
||||
});
|
||||
const response = await got(itemUrl);
|
||||
const data = cheerio.load(response.data);
|
||||
|
||||
if (itemUrl.indexOf('www.gov.cn') > -1) {
|
||||
@@ -65,7 +58,7 @@ module.exports = async (ctx) => {
|
||||
res.title = data('div#xxgk_content_redheadbg > h1').text();
|
||||
} else if (itemUrl.indexOf('jyb_') > -1) {
|
||||
res.description = data('div.TRS_Editor').html();
|
||||
res.title = data('div#content_body > h1').text();
|
||||
res.title = data('div.TRS_Editor').siblings('h1').first().text();
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -75,7 +68,7 @@ module.exports = async (ctx) => {
|
||||
title: infos.title,
|
||||
description: infos.description,
|
||||
link: itemUrl,
|
||||
pubDate: `${new Date().getFullYear()}-${item.find('span').text()}`,
|
||||
pubDate: parseDate(item.find('span').text(), 'MM-DD'),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
@@ -374,6 +374,17 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'moe.gov.cn': {
|
||||
_name: '中华人民共和国教育部',
|
||||
'.': [
|
||||
{
|
||||
title: '新闻',
|
||||
docs: 'https://docs.rsshub.app/government.html#zhong-hua-ren-min-gong-he-guo-jiao-yu-bu',
|
||||
source: ['/'],
|
||||
target: '/gov/moe/newest_file',
|
||||
},
|
||||
],
|
||||
},
|
||||
'nrta.gov.cn': {
|
||||
_name: '国家广播电视总局',
|
||||
'.': [
|
||||
|
||||
+15
-12
@@ -1,25 +1,28 @@
|
||||
module.exports = function (router) {
|
||||
router.get(/anhui\/kjt\/([\w\d/-]+)?/, require('./anhui/kjt'));
|
||||
router.get('/beijing/kw/:channel', require('./beijing/kw/index'));
|
||||
router.get('/shenzhen/hrss/szksy/:caty/:page?', require('./shenzhen/hrss/szksy/index'));
|
||||
router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index'));
|
||||
router.get('/shanghai/rsj/ksxm', require('./shanghai/rsj/ksxm'));
|
||||
router.get('/shanghai/wsjkw/yqtb', require('./shanghai/wsjkw/yqtb'));
|
||||
// ministry
|
||||
router.get('/fmprc/:category?', require('./mfa/wjdt'));
|
||||
router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq'));
|
||||
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
|
||||
router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index'));
|
||||
router.get('/sichuan/deyang/govpulicinfo/:countyName', require('./sichuan/deyang/govpulicinfo'));
|
||||
router.get('/mee/ywdt/:category?', require('./mee/ywdt'));
|
||||
router.get('/mfa/wjdt/:category?', require('./mfa/wjdt'));
|
||||
router.get('/miit/wjfb/:ministry', require('./miit/wjfb'));
|
||||
router.get('/miit/yjzj', require('./miit/yjzj'));
|
||||
router.get('/miit/zcwj', require('./miit/zcwj'));
|
||||
router.get('/miit/wjgs', require('./miit/wjgs'));
|
||||
router.get('/miit/zcjd', require('./miit/zcjd'));
|
||||
router.get('/mee/ywdt/:category?', require('./mee/ywdt'));
|
||||
router.get('/moe/:type', require('./moe/moe'));
|
||||
router.get('/nrta/news/:category?', require('./nrta/news'));
|
||||
router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu'));
|
||||
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
|
||||
router.get('/pbc/gzlw', require('./pbc/gzlw'));
|
||||
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
|
||||
router.get('/pbc/zcyj', require('./pbc/zcyj'));
|
||||
// province
|
||||
router.get(/anhui\/kjt\/([\w\d/-]+)?/, require('./anhui/kjt'));
|
||||
router.get('/beijing/kw/:channel', require('./beijing/kw/index'));
|
||||
router.get('/shenzhen/hrss/szksy/:caty/:page?', require('./shenzhen/hrss/szksy/index'));
|
||||
router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index'));
|
||||
router.get('/shanghai/rsj/ksxm', require('./shanghai/rsj/ksxm'));
|
||||
router.get('/shanghai/wsjkw/yqtb', require('./shanghai/wsjkw/yqtb'));
|
||||
router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq'));
|
||||
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
|
||||
router.get('/huizhou/zwgk/:category?', require('./huizhou/zwgk/index'));
|
||||
router.get('/sichuan/deyang/govpulicinfo/:countyName', require('./sichuan/deyang/govpulicinfo'));
|
||||
};
|
||||
|
||||
@@ -41,10 +41,11 @@ module.exports = async (ctx) => {
|
||||
link: `https://xueqiu.com/u/${id}`,
|
||||
description: `${data[0].user.screen_name} 的雪球${typename[type]}动态`,
|
||||
item: data.map((item) => {
|
||||
const description = item.description + (item.retweeted_status ? `<blockquote>${item.retweeted_status.user.screen_name}: ${item.retweeted_status.description}</blockquote>` : '');
|
||||
const retweetedStatus = item.retweeted_status ? `<blockquote>${item.retweeted_status.user.screen_name}: ${item.retweeted_status.description}</blockquote>` : '';
|
||||
const description = item.description + retweetedStatus;
|
||||
return {
|
||||
title: item.title ? item.title : description.replace(/<[^>]+>/g, ''),
|
||||
description,
|
||||
description: item.text ? (item.text + retweetedStatus) : description,
|
||||
pubDate: parseDate(item.created_at),
|
||||
link: `https://xueqiu.com${item.target}`,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user