diff --git a/docs/new-media.md b/docs/new-media.md index 94b8f651c8..8c92a21a20 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -175,6 +175,11 @@ pageClass: routes +## MIT 科技评论 + +### 首页 + + ## Nautilus ### 话题 diff --git a/docs/other.md b/docs/other.md index 90ed2cbb36..170bb1f3e2 100644 --- a/docs/other.md +++ b/docs/other.md @@ -66,6 +66,12 @@ pageClass: routes +## iYouport + +### 首页 + + + ## MobData ### 分析报告 diff --git a/docs/shopping.md b/docs/shopping.md index 5f97dc90a9..db8990ab2a 100644 --- a/docs/shopping.md +++ b/docs/shopping.md @@ -199,6 +199,12 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par +## 消费者报道 + +### 要闻 + + + ## 小米 ### 小米众筹 diff --git a/lib/router.js b/lib/router.js index 516ac56a6c..ed12b5e225 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2520,4 +2520,13 @@ router.get('/acwifi', require('./routes/acwifi')); // a岛匿名版 router.get('/adnmb/:pid/:page', require('./routes/adnmb/index')); +// MIT科技评论 +router.get('/mittrchina/article', require('./routes/mittrchina')); + +// 消费者报道 +router.get('/ccreports/article', require('./routes/ccreports')); + +// iYouPort +router.get('/iyouport/article', require('./routes/iyouport')); + module.exports = router; diff --git a/lib/routes/ccreports/index.js b/lib/routes/ccreports/index.js new file mode 100644 index 0000000000..4ff8e41ed8 --- /dev/null +++ b/lib/routes/ccreports/index.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://www.ccreports.com.cn/'; + const listData = await got.get(url); + const $1 = cheerio.load(listData.data); + const list = $1('.con h2'); + + ctx.state.data = { + title: '消费者报道', + link: url, + item: await Promise.all( + list + .slice(0, 5) + .map(async (index, item) => { + item = $1(item); + let fullTextGet = ''; + let fullText = ''; + let $2 = ''; + const contentUrl = item.find('a').attr('href'); + const description = await ctx.cache.tryGet(contentUrl, async () => { + fullTextGet = await got.get(contentUrl); + $2 = cheerio.load(fullTextGet.data); + $2('.h1p').remove(); + $2('.prenext').remove(); + $2('.pinglun').remove(); + fullText = $2('.content').html(); + return fullText; + }); + return { + title: item.find('a').text(), + description: description, + link: contentUrl, + }; + }) + .get() + ), + }; +}; diff --git a/lib/routes/iyouport/index.js b/lib/routes/iyouport/index.js new file mode 100644 index 0000000000..d13eedfa70 --- /dev/null +++ b/lib/routes/iyouport/index.js @@ -0,0 +1,44 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://www.iyouport.org/'; + const listData = await got.get(url); + const $1 = cheerio.load(listData.data); + const list = $1('.entry-title'); + + ctx.state.data = { + title: 'iYouPort', + link: url, + item: await Promise.all( + list + .slice(0, 10) + .map(async (index, item) => { + item = $1(item); + let fullTextGet = ''; + let fullText = ''; + let $2 = ''; + const contentUrl = item.find('a').attr('href'); + const description = await ctx.cache.tryGet(contentUrl, async () => { + fullTextGet = await got.get(contentUrl); + $2 = cheerio.load(fullTextGet.data); + $2('iframe').remove(); + $2('.wpcnt').remove(); + $2('.sharedaddy.sd-sharing-enabled').remove(); + $2('.sharedaddy.sd-block.sd-like.jetpack-likes-widget-wrapper.jetpack-likes-widget-unloaded').remove(); + $2('.jp-relatedposts').remove(); + // $2('img').removeAttr('data-lazy-srcset'); + // $2('img').removeAttr('srcset'); + fullText = $2('.entry-content').html(); + return fullText; + }); + return { + title: item.find('a').text(), + description: description, + link: contentUrl, + }; + }) + .get() + ), + }; +}; diff --git a/lib/routes/mittrchina/index.js b/lib/routes/mittrchina/index.js new file mode 100644 index 0000000000..3ea713efcc --- /dev/null +++ b/lib/routes/mittrchina/index.js @@ -0,0 +1,38 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://www.mittrchina.com/'; + const listData = await got.get(url); + const $1 = cheerio.load(listData.data); + const list = $1('.news-item-title'); + + ctx.state.data = { + title: 'MIT科技评论', + link: url, + item: await Promise.all( + list + .slice(0, 10) + .map(async (index, item) => { + item = $1(item); + let fullTextGet = ''; + let fullText = ''; + let $2 = ''; + const href = item.find('a').attr('href'); + const contentUrl = 'http://www.mittrchina.com' + href; + const description = await ctx.cache.tryGet(contentUrl, async () => { + fullTextGet = await got.get(contentUrl); + $2 = cheerio.load(fullTextGet.data); + fullText = $2('.content').html(); + return fullText; + }); + return { + title: item.find('a').text(), + description: description, + link: contentUrl, + }; + }) + .get() + ), + }; +};