fix(route): mysql (#11749)
This commit is contained in:
parent
c31a97b2ca
commit
58ecf7ae28
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue