diff --git a/docs/new-media.md b/docs/new-media.md index c038c3c34..a50184a8c 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -4509,18 +4509,6 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/ -## 中国计算机学会 - -### 新闻 - - - -| CCF 新闻 | CCF 聚焦 | ACM 信息 | -| ---------- | ------ | -------- | -| Media_list | Focus | ACM_News | - - - ## 中国科学院青年创新促进会 ### 最新博文 diff --git a/docs/study.md b/docs/study.md index a3a5ebf9b..46a92ea6e 100644 --- a/docs/study.md +++ b/docs/study.md @@ -342,18 +342,6 @@ path="/ctfhub/upcoming/:limit?" -## 计算机视觉专委 - -### 学术动态 - 分类 - - - -| 学术前沿 | 热点征文 | 学术会议 | -| ---- | ---- | ---- | -| xsqy | rdzw | xshy | - - - ## 金山词霸 ### 每日一句 @@ -659,12 +647,44 @@ path="/ctfhub/upcoming/:limit?" +## 中国计算机学会 + +### 新闻 + + + +| CCF 新闻 | CCF 聚焦 | ACM 信息 | +| ---------- | ------ | -------- | +| Media_list | Focus | ACM_News | + + + +### 计算机视觉专委会 - 学术动态 - 分类 + + + +| 学术前沿 | 热点征文 | 学术会议 | +| ---- | ---- | ---- | +| xsqy | rdzw | xshy | + + + +### 大数据专家委员会 + + + ## 中国留学网 ### 通知公告 +## 中国人工智能学会 + +### 学会动态 + + + ## 中国人事考试网 ### 通知公告 diff --git a/lib/router.js b/lib/router.js index 9b1d94e06..56168c4e0 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3541,7 +3541,7 @@ router.get('/vgn/:platform?', lazyloadRouteHandler('./routes/vgn/index')); router.get('/iea/:category?', lazyloadRouteHandler('./routes/iea/index')); // 中国计算机学会 -router.get('/ccf/news/:category?', lazyloadRouteHandler('./routes/ccf/news')); +// router.get('/ccf/news/:category?', lazyloadRouteHandler('./routes/ccf/news')); // The Brain router.get('/thebrain/:category?', lazyloadRouteHandler('./routes/thebrain/blog')); diff --git a/lib/v2/caai/index.js b/lib/v2/caai/index.js new file mode 100644 index 000000000..3d394a566 --- /dev/null +++ b/lib/v2/caai/index.js @@ -0,0 +1,22 @@ +const utils = require('./utils'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const base = utils.urlBase(ctx.params.caty); + const res = await got(base); + const info = utils.fetchAllArticles(res.data); + const $ = cheerio.load(res.data); + + const details = await Promise.all(info.map((e) => utils.detailPage(e, ctx.cache))); + + ctx.state.json = { + info, + }; + + ctx.state.data = { + title: '中国人工智能学会 - ' + $('.article-list h1').text(), + link: base, + item: details, + }; +}; diff --git a/lib/v2/caai/maintainer.js b/lib/v2/caai/maintainer.js new file mode 100644 index 000000000..823331250 --- /dev/null +++ b/lib/v2/caai/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:caty': ['tudou027'], +}; diff --git a/lib/v2/caai/radar.js b/lib/v2/caai/radar.js new file mode 100644 index 000000000..aa41e5cdd --- /dev/null +++ b/lib/v2/caai/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'caai.cn': { + _name: '中国人工智能学会', + '.': [ + { + title: '学会动态', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-ren-gong-zhi-neng-xue-hui', + source: ['/index.php'], + target: (_, url) => `/caai/${url.match(/\/(\d+)\.html/)[1]}`, + }, + ], + }, +}; diff --git a/lib/v2/caai/router.js b/lib/v2/caai/router.js new file mode 100644 index 000000000..5b857c686 --- /dev/null +++ b/lib/v2/caai/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:caty', require('./index')); +}; diff --git a/lib/v2/caai/templates/description.art b/lib/v2/caai/templates/description.art new file mode 100644 index 000000000..7755ee9f6 --- /dev/null +++ b/lib/v2/caai/templates/description.art @@ -0,0 +1 @@ +{{@ desc }} diff --git a/lib/v2/caai/utils.js b/lib/v2/caai/utils.js new file mode 100644 index 000000000..e7e79d754 --- /dev/null +++ b/lib/v2/caai/utils.js @@ -0,0 +1,46 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const { art } = require('@/utils/render'); +const path = require('path'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const base = 'http://www.caai.cn'; + +const urlBase = (caty) => base + `/index.php?s=/home/article/index/id/${caty}.html`; + +const renderDesc = (desc) => + art(path.join(__dirname, 'templates/description.art'), { + desc, + }); + +const detailPage = (e, cache) => + cache.tryGet(e.link, async () => { + const result = await got(e.link); + const $ = cheerio.load(result.data); + e.description = $('div.article').html(); + return e; + }); + +const fetchAllArticles = (data) => { + const $ = cheerio.load(data); + const articles = $('div.article-list > ul > li'); + const info = articles.toArray().map((e) => { + const c = $(e); + const r = { + title: c.find('h3 a[href]').text().trim(), + link: base + c.find('h3 a[href]').attr('href'), + pubDate: timezone(parseDate(c.find('h4').text().trim(), 'YYYY-MM-DD'), +8), + }; + return r; + }); + return info; +}; + +module.exports = { + BASE: base, + urlBase, + fetchAllArticles, + detailPage, + renderDesc, +}; diff --git a/lib/v2/ccfcv/index.js b/lib/v2/ccf/ccfcv/index.js similarity index 95% rename from lib/v2/ccfcv/index.js rename to lib/v2/ccf/ccfcv/index.js index 0f3f43ddc..d660486b8 100644 --- a/lib/v2/ccfcv/index.js +++ b/lib/v2/ccf/ccfcv/index.js @@ -4,7 +4,7 @@ const { parseDate } = require('@/utils/parse-date'); const { art } = require('@/utils/render'); const path = require('path'); -const rootUrl = 'http://ccfcv.ccf.org.cn'; +const rootUrl = 'https://tc.ccf.org.cn'; const cateTitleMap = { xsdt: { @@ -48,7 +48,7 @@ module.exports = async (ctx) => { if (item.status !== 404) { const content = cheerio.load(detailResponse.data); const pdfUrl = content('div.g-box1 p a').attr('href'); - item.description = art(path.join(__dirname, 'templates/description.art'), { + item.description = art(path.join(__dirname, '../templates/ccfcv/description.art'), { pdfUrl, }); } diff --git a/lib/v2/ccf/maintainer.js b/lib/v2/ccf/maintainer.js new file mode 100644 index 000000000..d17abb4e0 --- /dev/null +++ b/lib/v2/ccf/maintainer.js @@ -0,0 +1,5 @@ +module.exports = { + '/ccfcv/:channel/:category': ['elxy'], + '/news/:category?': ['nczitzk'], + '/tfbd/:caty/:id': ['tudou027'], +}; diff --git a/lib/routes/ccf/news.js b/lib/v2/ccf/news.js similarity index 67% rename from lib/routes/ccf/news.js rename to lib/v2/ccf/news.js index 1c927d654..2ba1bc2dd 100644 --- a/lib/routes/ccf/news.js +++ b/lib/v2/ccf/news.js @@ -1,42 +1,36 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { const category = ctx.params.category || 'Media_list'; const rootUrl = 'https://www.ccf.org.cn'; - const currentUrl = `${rootUrl}/${category}`; - const response = await got({ - method: 'get', - url: currentUrl, - }); + const currentUrl = `${rootUrl}/${category}/`; + const response = await got(currentUrl); const $ = cheerio.load(response.data); const list = $('.tit a') - .slice(0, 10) - .map((_, item) => { + .toArray() + .map((item) => { item = $(item); return { title: item.text(), link: `${rootUrl}${item.attr('href')}`, }; - }) - .get(); + }); const items = await Promise.all( list.map((item) => ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, - }); + const detailResponse = await got(item.link); const content = cheerio.load(detailResponse.data); content('.new_info .num').remove(); item.description = content('.txt').html(); - item.pubDate = new Date(content('.new_info span').text()).toUTCString(); + item.pubDate = parseDate(content('.new_info span').text()); return item; }) diff --git a/lib/v2/ccf/radar.js b/lib/v2/ccf/radar.js new file mode 100644 index 000000000..02cdbbaf3 --- /dev/null +++ b/lib/v2/ccf/radar.js @@ -0,0 +1,41 @@ +module.exports = { + 'ccf.org.cn': { + _name: '中国计算机学会', + '.': [ + { + title: '新闻', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-ji-suan-ji-xue-hui', + source: ['/:category', '/'], + target: '/ccf/news/:category', + }, + ], + ccfcv: [ + { + title: '计算机视觉专委会 - 学术动态 - 学术前沿', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-ji-suan-ji-xue-hui', + source: ['/ccfcv/xsdt/xsqy/'], + target: '/ccf/ccfcv/xsdt/xsqy', + }, + { + title: '计算机视觉专委会 - 学术动态 - 热点征文', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-ji-suan-ji-xue-hui', + source: ['/ccfcv/xsdt/rdzw/'], + target: '/ccf/ccfcv/xsdt/rdzw', + }, + { + title: '计算机视觉专委会 - 学术动态 - 学术会议', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-ji-suan-ji-xue-hui', + source: ['/ccfcv/xsdt/xshy/'], + target: '/ccf/ccfcv/xsdt/xshy', + }, + ], + tfbd: [ + { + title: '大数据专家委员会', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-ji-suan-ji-xue-hui', + source: ['/tfbd/:caty/:id', '/'], + target: '/ccf/tfbd/:caty/:id', + }, + ], + }, +}; diff --git a/lib/v2/ccf/router.js b/lib/v2/ccf/router.js new file mode 100644 index 000000000..484dfb48f --- /dev/null +++ b/lib/v2/ccf/router.js @@ -0,0 +1,5 @@ +module.exports = function (router) { + router.get('/ccfcv/:channel/:category', require('./ccfcv/index')); + router.get('/news/:category?', require('./news')); + router.get('/tfbd/:caty/:id', require('./tfbd/index')); +}; diff --git a/lib/v2/ccfcv/templates/description.art b/lib/v2/ccf/templates/ccfcv/description.art similarity index 100% rename from lib/v2/ccfcv/templates/description.art rename to lib/v2/ccf/templates/ccfcv/description.art diff --git a/lib/v2/ccf/templates/tfbd/description.art b/lib/v2/ccf/templates/tfbd/description.art new file mode 100644 index 000000000..7755ee9f6 --- /dev/null +++ b/lib/v2/ccf/templates/tfbd/description.art @@ -0,0 +1 @@ +{{@ desc }} diff --git a/lib/v2/ccf/tfbd/index.js b/lib/v2/ccf/tfbd/index.js new file mode 100644 index 000000000..6d488b67f --- /dev/null +++ b/lib/v2/ccf/tfbd/index.js @@ -0,0 +1,22 @@ +const utils = require('./utils'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const base = utils.urlBase(ctx.params.caty, ctx.params.id); + const res = await got(base); + const info = utils.fetchAllArticles(res.data); + const $ = cheerio.load(res.data); + + const details = await Promise.all(info.map((e) => utils.detailPage(e, ctx.cache))); + + ctx.state.json = { + info, + }; + + ctx.state.data = { + title: '大数据专家委员会 - ' + $('.position a:last-child').text(), + link: base, + item: details, + }; +}; diff --git a/lib/v2/ccf/tfbd/utils.js b/lib/v2/ccf/tfbd/utils.js new file mode 100644 index 000000000..c24fead50 --- /dev/null +++ b/lib/v2/ccf/tfbd/utils.js @@ -0,0 +1,47 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const { art } = require('@/utils/render'); +const path = require('path'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const base = 'http://tfbd.ccf.org.cn'; + +const urlBase = (caty, id) => base + `/tfbd/${caty}/${id}/`; + +const renderDesc = (desc) => + art(path.join(__dirname, '../templates/tfbd/description.art'), { + desc, + }); + +const detailPage = (e, cache) => + cache.tryGet(e.link, async () => { + const result = await got(e.link); + const $ = cheerio.load(result.data); + e.description = $('div.articleCon').html(); + + return e; + }); + +const fetchAllArticles = (data) => { + const $ = cheerio.load(data); + const articles = $('div.file-list div.article-item'); + const info = articles.toArray().map((e) => { + const c = $(e); + const r = { + title: c.find('h3 a[href]').text().trim(), + link: base + c.find('h3 a[href]').attr('href'), + pubDate: timezone(parseDate(c.find('p').text().trim(), 'YYYY-MM-DD'), +8), + }; + return r; + }); + return info; +}; + +module.exports = { + BASE: base, + urlBase, + fetchAllArticles, + detailPage, + renderDesc, +}; diff --git a/lib/v2/ccfcv/maintainer.js b/lib/v2/ccfcv/maintainer.js deleted file mode 100644 index 33ae7d4cb..000000000 --- a/lib/v2/ccfcv/maintainer.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - '/:channel/:category': ['elxy'], -}; diff --git a/lib/v2/ccfcv/radar.js b/lib/v2/ccfcv/radar.js deleted file mode 100644 index 2cf9202fd..000000000 --- a/lib/v2/ccfcv/radar.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - 'ccfcv.ccf.org.cn': { - _name: '计算机视觉专委会', - www: [ - { - title: '学术动态 - 学术前沿', - docs: 'https://docs.rsshub.app/study.html#ji-suan-ji-shi-jue-zhuan-wei-hui', - source: ['/ccfcv/xsdt/xsqy/'], - target: '/ccfcv/xsdt/xsqy', - }, - { - title: '学术动态 - 热点征文', - docs: 'https://docs.rsshub.app/study.html#ji-suan-ji-shi-jue-zhuan-wei-hui', - source: ['/ccfcv/xsdt/rdzw/'], - target: '/ccfcv/xsdt/rdzw', - }, - { - title: '学术动态 - 学术会议', - docs: 'https://docs.rsshub.app/study.html#ji-suan-ji-shi-jue-zhuan-wei-hui', - source: ['/ccfcv/xsdt/xshy/'], - target: '/ccfcv/xsdt/xshy', - }, - ], - }, -}; diff --git a/lib/v2/ccfcv/router.js b/lib/v2/ccfcv/router.js deleted file mode 100644 index f487b5733..000000000 --- a/lib/v2/ccfcv/router.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function (router) { - router.get('/:channel/:category', require('./index')); -};