optimize directory structure

This commit is contained in:
DIYgod
2018-12-26 18:35:10 +08:00
parent c68251e461
commit 38a90e29b0
475 changed files with 52 additions and 52 deletions

View File

@@ -0,0 +1,31 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await axios({
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,
};
};