const axios = require('@/utils/axios'); const host = 'https://www.curseforge.com'; const cheerio = require('cheerio'); module.exports = async (ctx) => { const gameid = ctx.params.gameid; const catagoryid = ctx.params.catagoryid; const projectid = ctx.params.projectid; const filePage = host + `/${gameid}/${catagoryid}/${projectid}/files`; const response = await axios({ method: 'get', url: filePage, }); const data = response.data; const $ = cheerio.load(data); const list = $('tr.project-file-list__item'); ctx.state.data = { title: `CurseForge - ${$('h2.name').text()}`, link: filePage, description: 'CurseForge文件更新提醒', item: list .map((i, item) => ({ title: $(item) .find('span.table__content.file__name.full') .text() .trim(), description: `
FileType FileName FileSize Download
${$(item) .find('td.project-file__release-type > span') .attr('title')} ${$(item) .find('span.table__content.file__name.full') .text() .trim()} ${$(item) .find('span.table__content.file__size') .text() .trim()} Click Me
`, link: filePage, pubDate: new Date( 1000 * $(item) .find('td.project-file__date-uploaded abbr') .attr('data-epoch') ).toUTCString(), })) .get(), }; };