* refactor: add no-implicit-coercion rule for ESLint * fix: errors from deepscan * fix: errors from deepscan * fix: errors from deepscan * fix: errors from deepscan * fix: errors from deepscan * Update docs/en/joinus/quick-start.md Co-authored-by: Sukka <isukkaw@gmail.com> * Update docs/joinus/quick-start.md Co-authored-by: Sukka <isukkaw@gmail.com> * Update lib/routes/av01/tag.js Co-authored-by: Sukka <isukkaw@gmail.com> * Update lib/routes/gov/taiwan/mnd.js Co-authored-by: Sukka <isukkaw@gmail.com> * Update lib/routes/ps/product.js Co-authored-by: Sukka <isukkaw@gmail.com> * refactor: minify html string Co-authored-by: Sukka <isukkaw@gmail.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const type = ctx.params.type;
|
|
let url = `https://www.tuicool.com/mags/${type}`;
|
|
if (type === 'prog') {
|
|
url = 'https://www.tuicool.com/mags';
|
|
}
|
|
const res = await got({
|
|
method: 'get',
|
|
url,
|
|
});
|
|
url = 'https://www.tuicool.com' + cheerio.load(res.data)('.mag-period-item a').attr('href');
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url,
|
|
});
|
|
|
|
const $ = cheerio.load(response.data);
|
|
const list = $('.article-title');
|
|
|
|
ctx.state.data = {
|
|
title: $('title').text(),
|
|
link: 'https://www.tuicool.com/',
|
|
item:
|
|
list &&
|
|
list
|
|
.map((index, item) => {
|
|
item = $(item);
|
|
return {
|
|
title: item.find('.title').text(),
|
|
description: `推酷:${item.find('.title').text()}`,
|
|
pubDate: new Date($('.period-title sub').text().substring(1, 11)).toUTCString(),
|
|
link: String(item.find('a').attr('href')),
|
|
};
|
|
})
|
|
.get(),
|
|
};
|
|
};
|