fix(route): cnbeta (#13714)
This commit is contained in:
parent
b1f2be63ce
commit
125c24eb97
|
|
@ -15,18 +15,24 @@ module.exports = async (ctx) => {
|
|||
const $ = cheerio.load(response.data);
|
||||
|
||||
const token = encodeURI($('meta[name="csrf-token"]').attr('content'));
|
||||
const apiUrl = `${rootUrl}/home/more?&type=${$('div[data-type]').attr('data-type')}&page=1&_csrf=${token}&_=${new Date().getTime()}`;
|
||||
const apiUrl = `${rootUrl}/home/more?&type=${$('div[data-type]').data('type')}&page=1&_csrf=${token}&_=${Date.now()}`;
|
||||
|
||||
response = await got(apiUrl);
|
||||
|
||||
const items = response.data.result.list.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.hometext,
|
||||
author: item.source.split('@http')[0],
|
||||
pubDate: timezone(parseDate(item.inputtime), +8),
|
||||
link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
|
||||
category: item.label.name,
|
||||
}));
|
||||
const items = type
|
||||
? response.data.result.list.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.hometext,
|
||||
author: item.source.split('@http')[0],
|
||||
pubDate: timezone(parseDate(item.inputtime), +8),
|
||||
link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
|
||||
category: item.label.name,
|
||||
}))
|
||||
: response.data.result.map((item) => ({
|
||||
title: item.title,
|
||||
link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
|
||||
category: item.label.name,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://www.cnbeta.com.tw';
|
||||
|
||||
|
|
@ -17,6 +19,7 @@ module.exports = {
|
|||
|
||||
item.description = content('.article-summary').html() + content('.article-content').html();
|
||||
item.author = content('header.title div.meta span.source').text();
|
||||
item.pubDate ??= timezone(parseDate(content('.meta span').first().text(), 'YYYY年MM月DD日 HH:mm'), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue