feat: 新增iYouport、消费者报道、MIT科技评论 (#4378)

This commit is contained in:
EsuRt
2020-04-13 19:52:18 +08:00
committed by GitHub
parent 6ddeb99ebd
commit 9df7b9f26c
7 changed files with 148 additions and 0 deletions

View File

@@ -175,6 +175,11 @@ pageClass: routes
<Route author="Cerebrater" example="/matters/author/az" path="/matters/author/:uid" :paramsDesc="['作者 id可在作者主頁的 URL 找到']" radar="1"/> <Route author="Cerebrater" example="/matters/author/az" path="/matters/author/:uid" :paramsDesc="['作者 id可在作者主頁的 URL 找到']" radar="1"/>
## MIT 科技评论
### 首页
<Route author="EsuRt" example="/mittrchina/article" path="/mittrchina"/>
## Nautilus ## Nautilus
### 话题 ### 话题

View File

@@ -66,6 +66,12 @@ pageClass: routes
<Route author="LogicJake" example="/instapaper/person/viridiano" path="/instapaper/person"/> <Route author="LogicJake" example="/instapaper/person/viridiano" path="/instapaper/person"/>
## iYouport
### 首页
<Route author="EsuRt" example="/iyouport/article" path="/iyouport"/>
## MobData ## MobData
### 分析报告 ### 分析报告

View File

@@ -199,6 +199,12 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par
<Route author="LogicJake" example="/weidian/goods/431508863" path="/weidian/goods/:id" :paramsDesc="['商铺 id']"/> <Route author="LogicJake" example="/weidian/goods/431508863" path="/weidian/goods/:id" :paramsDesc="['商铺 id']"/>
## 消费者报道
### 要闻
<Route author="EsuRt" example="/ccreports/article" path="/ccreports"/>
## 小米 ## 小米
### 小米众筹 ### 小米众筹

View File

@@ -2520,4 +2520,13 @@ router.get('/acwifi', require('./routes/acwifi'));
// a岛匿名版 // a岛匿名版
router.get('/adnmb/:pid/:page', require('./routes/adnmb/index')); 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; module.exports = router;

View File

@@ -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()
),
};
};

View File

@@ -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()
),
};
};

View File

@@ -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()
),
};
};