mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 16:20:27 +08:00
optimize directory structure
This commit is contained in:
32
lib/routes/tencent/wechat/announce.js
Normal file
32
lib/routes/tencent/wechat/announce.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { data: htmlString } = await axios({
|
||||
method: 'get',
|
||||
url: 'https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncementlist&lang=zh_CN',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(htmlString);
|
||||
const announceList = [];
|
||||
|
||||
$('.mp_news_list > .mp_news_item').each(function() {
|
||||
const $item = $(this);
|
||||
const $link = $item.find('a');
|
||||
const time = $item.find('.read_more').text();
|
||||
const title = $item.find('strong').text();
|
||||
|
||||
announceList.push({
|
||||
title: `${time} ${title}`,
|
||||
link: `https://mp.weixin.qq.com${$link.attr('href')}`,
|
||||
description: title,
|
||||
pubDate: new Date(time).toUTCString(),
|
||||
});
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '微信公众平台-系统公告栏目',
|
||||
link: 'https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncementlist&lang=zh_CN&token=',
|
||||
item: announceList,
|
||||
};
|
||||
};
|
||||
59
lib/routes/tencent/wechat/miniprogram/plugins.js
Normal file
59
lib/routes/tencent/wechat/miniprogram/plugins.js
Normal file
@@ -0,0 +1,59 @@
|
||||
const axios = require('../../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'https://developers.weixin.qq.com/community/plugins';
|
||||
const response = await axios({
|
||||
method: 'post',
|
||||
url: `https://developers.weixin.qq.com/community/ngi/plugins/cases?random=${Math.random()}`,
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
|
||||
const { pluginCases } = response.data.data;
|
||||
const resultItem = await Promise.all(
|
||||
pluginCases.map(async (plugin) => {
|
||||
const item = {
|
||||
title: plugin.title,
|
||||
description: '',
|
||||
link: `https://developers.weixin.qq.com/community/develop/doc/${plugin.docid}`,
|
||||
author: plugin.nickname,
|
||||
pubDate: new Date(plugin.createTime * 1000).toUTCString(),
|
||||
};
|
||||
const url = `https://developers.weixin.qq.com/community/ngi/doc/detail/${plugin.docid}`;
|
||||
const key = `miniprogram-plugin: ${url}`;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
if (value) {
|
||||
item.description = value;
|
||||
} else {
|
||||
const pluginDetail = await axios({
|
||||
method: 'get',
|
||||
url: `${url}?random=${Math.random()}`,
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
const id = 'x-rsshub';
|
||||
const $ = cheerio.load(`<div id="${id}">${pluginDetail.data.data.Content}</div>`);
|
||||
$('img').each((index, item) => {
|
||||
item = $(item);
|
||||
item.attr('src', item.attr('data-src'));
|
||||
item.attr('referrerpolicy', 'no-referrer');
|
||||
});
|
||||
|
||||
item.description = $(`#${id}`).html();
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '微信小程序插件',
|
||||
link,
|
||||
item: resultItem,
|
||||
};
|
||||
};
|
||||
26
lib/routes/tencent/wechat/wasi.js
Normal file
26
lib/routes/tencent/wechat/wasi.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://q.qnmlgb.tech/w/api/articles?_ls=&_fmt=authorSimple&_page=author&_author_id=${id}&_sub_tab=&_tab=author`,
|
||||
headers: {
|
||||
Referer: `https://w.qnmlgb.tech/authors/${id}/`,
|
||||
},
|
||||
});
|
||||
const data = response.data.result.articles[0];
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${data.author.nickname}微信公众号`,
|
||||
link: `https://w.qnmlgb.tech/authors/${id}/`,
|
||||
description: data.author.profile_desc,
|
||||
item: data.sub_articles.map((item) => ({
|
||||
title: item.article.title,
|
||||
description: `${item.article.digest}<img referrerpolicy="no-referrer" src="${item.article.cover}">`,
|
||||
pubDate: new Date(item.article.datetime * 1000).toUTCString(),
|
||||
link: item.article.content_url,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user