mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
feat: add wechat miniprogram changelogs (#4578)
This commit is contained in:
47
lib/routes/tencent/wechat/miniprogram/wxcloud.js
Normal file
47
lib/routes/tencent/wechat/miniprogram/wxcloud.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference/changelog` + (ctx.params.caty ? '-' + ctx.params.caty : '') + `.html`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const name = $('#docContent .content h2').text();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name}`,
|
||||
link: link,
|
||||
item: ctx.params.caty
|
||||
? $('#docContent .content h3')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const title = item.text().replace(/[\s|#]/g, '');
|
||||
return {
|
||||
title: title,
|
||||
description: item.next().html(),
|
||||
pubDate: new Date(new RegExp(/\d{4}.\d{2}.\d{2}/).exec(title) + ' GMT+8').toUTCString(),
|
||||
link: link + item.find('a.header-anchor').attr('href'),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
: $('#docContent .custom')
|
||||
.map((_, item) => {
|
||||
$('#docContent .custom h2').remove();
|
||||
const title = $('#docContent .custom h3')
|
||||
.first()
|
||||
.text()
|
||||
.replace(/[\s|#]/g, '');
|
||||
return {
|
||||
title: title,
|
||||
description: $(item).html(),
|
||||
pubDate: new Date(new RegExp(/\d{4}.\d{2}.\d{2}/).exec(title) + ' GMT+8').toUTCString(),
|
||||
link: link,
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
description: `${name}`,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user