fix(route): sina responsed 403 (#9304)

* fix(route): sina responsed 403

* fix: use parseDate

fix: promise overhead
This commit is contained in:
Fatpandac 2022-03-11 22:32:06 +08:00 committed by GitHub
parent 727f17a15f
commit e50dc7058e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -1,8 +1,13 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const response = await got.get(`https://feed.mix.sina.com.cn/api/roll/get?pageid=372&lid=2431&k=&num=50&page=1&r=${Math.random()}&callback=&_=${new Date().getTime()}`);
const response = await got(`https://feed.mix.sina.com.cn/api/roll/get?pageid=372&lid=2431&k=&num=50&page=1&r=${Math.random()}&callback=&_=${new Date().getTime()}`, {
headers: {
Referer: 'https://tech.sina.com.cn/',
},
});
const list = response.data.result.data;
const out = await Promise.all(
@ -22,9 +27,9 @@ module.exports = async (ctx) => {
title,
link,
description,
pubDate: new Date(date).toUTCString(),
pubDate: parseDate(date),
};
return Promise.resolve(single);
return single;
})
);