feat: add zaker channel (#2550)

* feat: add zaker channel

* feat: add zaker channel

* feat: add zaker channel
This commit is contained in:
Cloud
2019-07-04 16:28:26 +08:00
committed by DIYgod
parent bb63129d50
commit 062e6bce81
3 changed files with 11 additions and 3 deletions

View File

@@ -256,6 +256,10 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="LogicJake" example="/zaker/source/12291" path="/zaker/source/:id" :paramsDesc="['source id可在 URL 中找到']"/>
### channel
<Route author="kt286" example="/zaker/channel/13" path="/zaker/source/:id" :paramsDesc="['channel id可在 URL 中找到']"/>
## 爱范儿 ifanr
### 爱范儿频道

View File

@@ -1215,7 +1215,7 @@ router.get('/checkee/:dispdate', require('./routes/checkee/index'));
router.get('/iresearch/report', require('./routes/iresearch/report'));
// ZAKER
router.get('/zaker/source/:id', require('./routes/zaker/source'));
router.get('/zaker/:type/:id', require('./routes/zaker/source'));
// Matters
router.get('/matters/topics', require('./routes/matters/topics'));

View File

@@ -3,8 +3,9 @@ const cheerio = require('cheerio');
const date_util = require('@/utils/date');
module.exports = async (ctx) => {
const type = ctx.params.type || 'source';
const id = ctx.params.id;
const link = `http://www.myzaker.com/source/${id}`;
const link = `http://www.myzaker.com/${type}/${id}`;
const response = await got.get(link);
const $ = cheerio.load(response.data);
@@ -40,10 +41,13 @@ module.exports = async (ctx) => {
method: 'get',
headers: {
Referer: link,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0',
},
});
const $ = cheerio.load(response.data);
$('img').each((index, elem) => {
const $elem = $(elem);
$elem.attr('referrerpolicy', 'no-referrer');
});
const description = $('div.article_content div')
.html()
.replace(/data-original/g, `src`);