From 9df7b9f26c5638d906174ae765a809b05ffbd622 Mon Sep 17 00:00:00 2001
From: EsuRt <15177069+EsuRt@users.noreply.github.com>
Date: Mon, 13 Apr 2020 19:52:18 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EiYouport=E3=80=81?=
=?UTF-8?q?=E6=B6=88=E8=B4=B9=E8=80=85=E6=8A=A5=E9=81=93=E3=80=81MIT?=
=?UTF-8?q?=E7=A7=91=E6=8A=80=E8=AF=84=E8=AE=BA=20(#4378)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/new-media.md | 5 ++++
docs/other.md | 6 +++++
docs/shopping.md | 6 +++++
lib/router.js | 9 +++++++
lib/routes/ccreports/index.js | 40 +++++++++++++++++++++++++++++++
lib/routes/iyouport/index.js | 44 ++++++++++++++++++++++++++++++++++
lib/routes/mittrchina/index.js | 38 +++++++++++++++++++++++++++++
7 files changed, 148 insertions(+)
create mode 100644 lib/routes/ccreports/index.js
create mode 100644 lib/routes/iyouport/index.js
create mode 100644 lib/routes/mittrchina/index.js
diff --git a/docs/new-media.md b/docs/new-media.md
index 94b8f651c..8c92a21a2 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 90ed2cbb3..170bb1f3e 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 5f97dc90a..db8990ab2 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 516ac56a6..ed12b5e22 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 000000000..4ff8e41ed
--- /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 000000000..d13eedfa7
--- /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 000000000..3ea713efc
--- /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()
+ ),
+ };
+};