Files
RSSHub/lib/v2/huangz/index.js
T
331405d69e feat(route): 黄健宏博客 (#9553)
* ✨ feat(route): add blog: huangz

* 🐞 fix(route): huangz url missing

* 📃 docs(radar): update docs url

* 📃 docs(radar): fix url

* ✨ feat(route): add maintainer.js

* 🐞 fix(radar): fix huangz blog radar source

* Update lib/v2/huangz/index.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/huangz/radar.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/huangz/radar.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update index.js

* style: auto format

* docs: fix link break

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-04-17 21:33:27 +08:00

30 lines
738 B
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const BLOG_URL = 'https://blog.huangz.me/';
module.exports = async (ctx) => {
const resp = await got({
method: 'get',
url: BLOG_URL,
});
const $ = cheerio.load(resp.body);
const list = $('.toctree-l2');
const items = await Promise.all(
list.map((index, item) => {
const link = `${BLOG_URL}${$(item).find('a').attr('href')}`;
return ctx.cache.tryGet(link, () => ({
title: $(item).find('a').text(),
link,
}));
})
);
ctx.state.data = {
title: 'huangz/blog',
link: 'https://blog.huangz.me',
item: items,
};
};