Files
RSSHub/lib/routes/testerhome/newest.js
2019-06-03 18:03:05 +08:00

32 lines
960 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://testerhome.com/topics/last',
});
const $ = cheerio.load(response.data);
const resultItem = $('.item-list .topic')
.map((index, elem) => {
elem = $(elem);
const $link = elem.find('.title a');
const title = $link.attr('title');
return {
title,
link: `https://testerhome.com${$link.attr('href')}`,
description: title,
};
})
.get();
ctx.state.data = {
title: 'TesterHome-最新发布',
link: 'https://testerhome.com/topics/last',
description: 'TesterHome软件测试社区人气最旺的软件测试技术门户提供软件测试社区交流测试沙龙。',
item: resultItem,
};
};