mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 12:21:31 +08:00
* fix(route:aliyun/developer/group): 获取到的全是0 * Update lib/routes/aliyun/developer/group.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/aliyun/developer/group.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * refactor: migrate to v2 * refactor: use cache.tryGet * fix: add radar * fix: article parsing
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const url = 'http://mysql.taobao.org/monthly/';
|
|
const response = await got({ method: 'get', url });
|
|
const $ = cheerio.load(response.data);
|
|
|
|
const list = $("ul[class='posts'] > li")
|
|
.map((i, e) => {
|
|
const element = $(e);
|
|
const title = element.find('a').text().trim();
|
|
const link = `http://mysql.taobao.org${element.find('a').attr('href').trim()}/`;
|
|
return {
|
|
title,
|
|
description: '',
|
|
link,
|
|
};
|
|
})
|
|
.get();
|
|
|
|
const result = await Promise.all(
|
|
list.map((item) => {
|
|
const link = item.link;
|
|
|
|
return ctx.cache.tryGet(link, async () => {
|
|
const itemReponse = await got(link);
|
|
const itemElement = cheerio.load(itemReponse.data);
|
|
item.description = itemElement('.content').html();
|
|
return item;
|
|
});
|
|
})
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: $('title').text(),
|
|
link: url,
|
|
item: result.reverse(),
|
|
};
|
|
};
|