Files
RSSHub/lib/v2/yaohuo/index.js
2021-11-27 08:57:04 +00:00

31 lines
636 B
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'https://yaohuo.me';
const response = await got({
method: 'get',
url: rootUrl,
});
const $ = cheerio.load(response.data);
const items = $('.list a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
};
});
ctx.state.data = {
title: $('title').text(),
link: rootUrl,
item: items,
};
};