fix: 得到首页 (#6187)

This commit is contained in:
Ethan Shen 2020-11-24 19:52:07 +08:00 committed by GitHub
parent 7113ad0ce9
commit a31510e4db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -9,13 +9,19 @@ module.exports = async (ctx) => {
url: rootUrl,
});
const currentUrl = `${rootUrl}${response.data.match(new RegExp('<a href="(.*)">' + caty + '<\\/a>'))[1]}`;
const listUrl = `${rootUrl}${response.data.match(new RegExp('<a href="(.*)">年度日更<\\/a>'))[1]}`;
const listResponse = await got({
method: 'get',
url: listUrl,
});
const currentUrl = `${rootUrl}${listResponse.data.match(new RegExp('<span>' + caty + '<\\/span><a href="(.*)" rel="tag"><\\/a>'))[1].split('"')[0]}`;
const currentResponse = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(listResponse.data);
const $ = cheerio.load(currentResponse.data);
const list = $('.pro-info p a')
.slice(0, 10)