diff --git a/lib/routes/dongqiudi/result.js b/lib/routes/dongqiudi/result.js index 794eee95dd..21d83970d2 100644 --- a/lib/routes/dongqiudi/result.js +++ b/lib/routes/dongqiudi/result.js @@ -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} 比赛结果`,