diff --git a/docs/other.md b/docs/other.md index 86a660657..d3e16aa44 100644 --- a/docs/other.md +++ b/docs/other.md @@ -171,6 +171,12 @@ pageClass: routes +## NBA + +### 头条新闻 + + + ## ONE · 一个 ### 图片文字问答 diff --git a/lib/router.js b/lib/router.js index 73baca544..e60cd81ad 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/nba/app_news.js b/lib/routes/nba/app_news.js new file mode 100644 index 000000000..e6aa704c8 --- /dev/null +++ b/lib/routes/nba/app_news.js @@ -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 = ''; + + const item = { + title, + description, + pubDate, + link, + guid, + }; + + return item; + }); + + ctx.state.data = { + title: 'NBA - news', + link: 'https://kbsapp.sports.qq.com', + item: out, + }; +};