hotfix: cctv api (#3067)

This commit is contained in:
凉凉 2019-09-15 12:45:39 +08:00 committed by DIYgod
parent 1b45fdb2ed
commit 486481bef6
2 changed files with 9 additions and 9 deletions

View File

@ -327,9 +327,9 @@ category 对应的关键词有
<Route author="idealclover xyqfer" example="/cctv/world" path="/cctv/:category" :paramsDesc="['分类名']">
| 国内 | 国际 | 视频 | 科技 | 社会 | 法律 | 娱乐 | 每周质量报告 |
| ----- | ----- | ----- | ---- | ------- | ---- | ---- | ------------ |
| china | world | video | tech | society | law | ent | mzzlbg |
| 新闻 | 国内 | 国际 | 社会 | 法治 | 文娱 | 科技 | 生活 | 教育 | 每周质量报告 |
| ---- | ----- | ----- | ------- | ---- | ---- | ---- | ---- | ---- | ------------ |
| news | china | world | society | law | ent | tech | life | edu | mzzlbg |
</Route>

View File

@ -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);