const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { const type = ctx.params.type || ''; const rootUrl = 'https://ditto-cp.sourceforge.io'; const currentUrl = `${rootUrl}/${type === '' ? 'changeHistory.php' : `${type}/changes.php`}`; const response = await got({ method: 'get', url: currentUrl, }); const $ = cheerio.load(type === '' ? response.data : `
${item.text()}
`, }; }) .get(); ctx.state.data = { title: `Ditto clipboard manager ${type === '' ? '' : `(${type}) `}changes`, link: currentUrl, item: items, }; };