fix(route): 懂球帝赛果失效 (#8526)

fix #8221, fix #8468, fix #8560
This commit is contained in:
Jin
2022-02-02 03:44:24 +08:00
committed by GitHub
parent d2f4a5620a
commit d62365ec1a
+13 -25
View File
@@ -1,37 +1,25 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { JSDOM } = require('jsdom');
module.exports = async (ctx) => {
const team = ctx.params.team;
const link = `https://www.dongqiudi.com/team/${team}.html`;
const response = await got.get(link);
const $ = cheerio.load(response.data);
const teamName = $('h1.name').text();
const list = $('table.schedule_list tr.stat_list');
const out = [];
const dom = new JSDOM(response.data, {
runScripts: 'dangerously',
});
const data = dom.window.__NUXT__.data[0];
const resultData = data.teamScheduleData.filter((data) => data.fs_A && data.fs_B);
for (let i = 0; i < list.length; i++) {
const $ = cheerio.load(list[i]);
const teamName = data.teamDetail.base_info.team_name;
const score = $('td:nth-of-type(5)').text().trim();
if (score !== '-') {
const time = $('td.match_time_hidden').text();
const type = $('td.gameweek').text();
const home = $('td:nth-of-type(4)').text().trim();
const away = $('td:nth-of-type(6)').text().trim();
const title = `${type} ${home} ${score} ${away}`;
const single = {
title,
link,
pubDate: new Date(time),
guid: title,
};
out.push(single);
}
}
const out = resultData.map((result) => ({
title: `${result.match_title} ${result.team_A_name} ${result.fs_A}-${result.fs_B} ${result.team_B_name}`,
guid: result.match_id,
link: result.scheme.replace('dongqiudi:///game/', 'https://www.dongqiudi.com/liveDetail/'),
pubDate: result.start_time,
}));
ctx.state.data = {
title: `${teamName} 比赛结果`,