feat: 添加NBA频道 (#2553)

* [feat] 添加NBA频道

* [feat] 添加NBA频道

* [feature] 添加nba文档

* [fix] 去掉缓存

* [fix] 去掉console
This commit is contained in:
alizeegod 2019-07-04 16:53:35 +08:00 committed by DIYgod
parent 0a4e7807ed
commit 614869e371
3 changed files with 49 additions and 0 deletions

View File

@ -171,6 +171,12 @@ pageClass: routes
<Route author="brilon" example="/mobdata/report" path="/mobdata/report"/>
## NBA
### 头条新闻
<Route author="alizeegod" example="/nba/app_news" path="/nba/app_news"/>
## ONE · 一个
### 图片文字问答

View File

@ -1464,6 +1464,9 @@ router.get('/lolapp/recommend', require('./routes/lolapp/recommend'));
// 左岸读书
router.get('/zreading', require('./routes/zreading/home'));
// NBA
router.get('/nba/app_news', require('./routes/nba/app_news'));
// 天津产权交易中心
router.get('/tprtc/cqzr', require('./routes/tprtc/cqzr'));
router.get('/tprtc/qyzc', require('./routes/tprtc/qyzc'));

View File

@ -0,0 +1,40 @@
const got = require('@/utils/got');
const sourceTimezoneOffset = -8;
module.exports = async (ctx) => {
const id_url = 'https://sportsnba.qq.com/news/index?column=banner';
const articles = await got.get(id_url);
const articleIds = articles.data.data.map((article) => article.id);
const url = 'https://sportsnba.qq.com/news/item?column=banner&articleIds=' + articleIds.toString();
const response = await got.get(url);
const xmls = response.data.data;
const out = Object.keys(xmls).map((xml) => {
const data = xmls[xml];
const link = data.shareUrl;
const guid = data.newsId;
const title = data.title;
const time = new Date(data.pub_time);
time.setTime(time.getTime() + (sourceTimezoneOffset - time.getTimezoneOffset() / 60) * 60 * 60 * 1000);
const pubDate = time.toUTCString();
const description = '<img src="' + data.imgurl + '" referrerpolicy="no-referrer">';
const item = {
title,
description,
pubDate,
link,
guid,
};
return item;
});
ctx.state.data = {
title: 'NBA - news',
link: 'https://kbsapp.sports.qq.com',
item: out,
};
};