From 486481bef6fa71c277cf302b2094a0fcb3402ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Sun, 15 Sep 2019 12:45:39 +0800 Subject: [PATCH] hotfix: cctv api (#3067) --- docs/traditional-media.md | 6 +++--- lib/routes/cctv/utils/news.js | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/traditional-media.md b/docs/traditional-media.md index fb7e68c6e..2c1219ba4 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -327,9 +327,9 @@ category 对应的关键词有 -| 国内 | 国际 | 视频 | 科技 | 社会 | 法律 | 娱乐 | 每周质量报告 | -| ----- | ----- | ----- | ---- | ------- | ---- | ---- | ------------ | -| china | world | video | tech | society | law | ent | mzzlbg | +| 新闻 | 国内 | 国际 | 社会 | 法治 | 文娱 | 科技 | 生活 | 教育 | 每周质量报告 | +| ---- | ----- | ----- | ------- | ---- | ---- | ---- | ---- | ---- | ------------ | +| news | china | world | society | law | ent | tech | life | edu | mzzlbg | diff --git a/lib/routes/cctv/utils/news.js b/lib/routes/cctv/utils/news.js index bfad3de04..125f40435 100644 --- a/lib/routes/cctv/utils/news.js +++ b/lib/routes/cctv/utils/news.js @@ -2,24 +2,24 @@ const got = require('@/utils/got'); const path = require('path'); module.exports = async (category, ctx) => { - const url = `http://news.cctv.com/${category}/data/index.json`; + const url = `http://news.cctv.com/2019/07/gaiban/cmsdatainterface/page/${category}_1.jsonp`; const response = await got({ method: 'get', url: url, headers: { - Referer: url, + Referer: `http://news.cctv.com/${category}`, }, }); - const data = response.data; - const list = data.rollData; + const data = JSON.parse(response.data.slice(category.length + 1, -1)); + const list = data.data.list; const resultItem = await Promise.all( - list.map(async ({ title, url, dateTime, image }) => { + list.map(async ({ title, url, focus_date, image }) => { const item = { title, link: url, - pubDate: new Date(dateTime).toUTCString(), + pubDate: new Date(focus_date).toUTCString(), }; const key = `cctv-news: ${url}`; const value = await ctx.cache.get(key);