fix(route): mysql (#11749)

This commit is contained in:
Tony
2023-02-01 18:46:10 +08:00
committed by GitHub
parent c31a97b2ca
commit 58ecf7ae28
+9 -2
View File
@@ -1,15 +1,19 @@
const got = require('@/utils/got');
const config = require('@/config').value;
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const version = ctx.params.version ?? '8.0';
const rootUrl = 'https://dev.mysql.com';
const currentUrl = `${rootUrl}/doc/relnotes/mysql/${version}/en`;
const currentUrl = `${rootUrl}/doc/relnotes/mysql/${version}/en/`;
const response = await got({
method: 'get',
url: currentUrl,
headers: {
'user-agent': config.trueUA,
},
});
const $ = cheerio.load(response.data);
@@ -22,7 +26,7 @@ module.exports = async (ctx) => {
return {
title: item.text(),
link: `${currentUrl}/${item.attr('href')}`,
link: `${currentUrl}${item.attr('href')}`,
};
});
@@ -32,6 +36,9 @@ module.exports = async (ctx) => {
const detailResponse = await got({
method: 'get',
url: item.link,
headers: {
'user-agent': config.trueUA,
},
});
const content = cheerio.load(detailResponse.data);