mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-13 16:49:31 +08:00
* add * add audiobar * add * add doc * use parseDate * fix * add v2 * remove old doc * Update docs/bbs.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/audiobar/latest.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/audiobar/maintainer.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/audiobar/router.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix doc * Update lib/v2/audiobar/radar.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix: docs link Co-authored-by: zhuty <zhuty@sci99.com> Co-authored-by: Tony <TonyRL@users.noreply.github.com>
54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const iconv = require('iconv-lite');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const timezone = require('@/utils/timezone');
|
|
|
|
const rootUrl = 'http://www.audiobar.cn/';
|
|
|
|
module.exports = async (ctx) => {
|
|
const currentUrl = `${rootUrl}/all.php`;
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
responseType: 'buffer',
|
|
});
|
|
const data = iconv.decode(response.data, 'gb2312');
|
|
const $ = cheerio.load(data);
|
|
|
|
const list = $('.thread_every_container_div')
|
|
.map((_, item) => {
|
|
item = $(item);
|
|
|
|
const link = item.find('.thread_subject').attr('href');
|
|
const dateStr = item.find('.atrd_span').text().slice(-26).replace(' ', '');
|
|
return {
|
|
title: item.find('.thread_subject').text().replace('\n', '').replace(' ', ''),
|
|
link: link.indexOf('http') > -1 ? link : `${rootUrl}${link}`,
|
|
pubDate: timezone(parseDate(dateStr, 'YY-M-D HH:mm'), +8),
|
|
};
|
|
})
|
|
.get();
|
|
const items = await Promise.all(
|
|
list.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
const detailResponse = await got({
|
|
method: 'get',
|
|
url: item.link,
|
|
responseType: 'buffer',
|
|
});
|
|
const detailResponsedata = iconv.decode(detailResponse.data, 'gb2312');
|
|
const content = cheerio.load(detailResponsedata);
|
|
item.description = content('.zhengwen_div').text().replace('Your browser does not support HTML5, please change another browser.', '');
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
ctx.state.data = {
|
|
title: '音频应用-最新主题',
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|