mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
* feat(route): add u3c3 - u3c3 的几个子分类页面 - 搜索功能 - torrent/magnet - 中英文档 * Update docs/en/multimedia.md docs(u3c3): fix typo in english document Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/u3c3/index.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * feat(radar): add u3c3.com radar * refactor(u3c3): clean code * docs(u3c3): fix lost info in u3c3 english document * fix(radar): fix typo in u3c3 radar Co-authored-by: noname <no-email@no.email>
60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const type = ctx.params.type;
|
|
// should be:
|
|
// undefined
|
|
// U3C3
|
|
// Videos
|
|
// Photo
|
|
// Book
|
|
// Game
|
|
// Software
|
|
// Other
|
|
const rootURL = 'https://www.u3c3.com';
|
|
let currentURL;
|
|
let title;
|
|
if (typeof type === 'undefined') {
|
|
currentURL = rootURL;
|
|
title = 'home - u3c3';
|
|
} else if (type === 'search') {
|
|
const keyword = typeof ctx.params.keyword === 'undefined' ? '' : ctx.params.keyword;
|
|
currentURL = `${rootURL}/?search=${keyword}`;
|
|
title = `search ${keyword} - u3c3`;
|
|
} else {
|
|
currentURL = `${rootURL}/?type=${type}&p=1`;
|
|
title = `${type} - u3c3`;
|
|
}
|
|
|
|
const response = await got(currentURL);
|
|
const $ = cheerio.load(response.data);
|
|
|
|
const items = $('body > div.container > div.table-responsive > table > tbody > tr')
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
const title = item.find('td:nth-of-type(2) > a ').attr('title');
|
|
const guid = rootURL + item.find('td:nth-of-type(2) > a').attr('href');
|
|
const link = guid;
|
|
const pubDate = item.find('td:nth-of-type(5)').text();
|
|
const enclosure_url = item.find('td:nth-of-type(3) > a:nth-of-type(2)').attr('href');
|
|
return {
|
|
title,
|
|
guid,
|
|
link,
|
|
pubDate,
|
|
|
|
enclosure_url,
|
|
enclosure_type: 'application/x-bittorrent',
|
|
};
|
|
});
|
|
|
|
ctx.state.data = {
|
|
title,
|
|
description: title,
|
|
link: currentURL,
|
|
item: items,
|
|
};
|
|
};
|