fix(route): mysql (#11749)

This commit is contained in:
Tony 2023-02-01 10:46:10 +00:00 committed by GitHub
parent c31a97b2ca
commit 58ecf7ae28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

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);