feat: add 直播吧 (#2379)
This commit is contained in:
parent
4531de80f9
commit
fda0b82a88
|
|
@ -720,6 +720,16 @@ pageClass: routes
|
|||
|
||||
<Route author="Maecenas" example="/1point3acres/user/1/posts" path="/1point3acres/user/:id/posts" :paramsDesc="['用户 id,可在 Instant 版网站的个人主页 URL 找到']"/>
|
||||
|
||||
## 直播吧
|
||||
|
||||
### 子论坛
|
||||
|
||||
<Route author="LogicJake" example="/zhibo8/forum/8" path="/zhibo8/forum/:id" :paramsDesc="['子论坛 id,可在子论坛 URL 找到']"/>
|
||||
|
||||
### 回帖
|
||||
|
||||
<Route author="LogicJake" example="/zhibo8/post/2601615" path="/zhibo8/post/:id" :paramsDesc="['帖子 id,可在帖子 URL 找到']"/>
|
||||
|
||||
## 知乎
|
||||
|
||||
### 收藏夹
|
||||
|
|
|
|||
|
|
@ -1397,6 +1397,10 @@ router.get('/005tv/zx/latest', require('./routes/005tv/zx'));
|
|||
// Polimi News
|
||||
router.get('/polimi/news/:language?', require('./routes/polimi/news'));
|
||||
|
||||
// 直播吧
|
||||
router.get('/zhibo8/forum/:id', require('./routes/zhibo8/forum'));
|
||||
router.get('/zhibo8/post/:id', require('./routes/zhibo8/post'));
|
||||
|
||||
// 东方网-上海
|
||||
router.get('/eastday/sh', require('./routes/eastday/sh'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const link = `https://bbs.zhibo8.cc/forum/list/?fid=${id}`;
|
||||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const title = $('div.intro > h2').text();
|
||||
const list = $('table.topic-list > tbody:nth-child(3) > tr');
|
||||
|
||||
const out = await Promise.all(
|
||||
list
|
||||
.map(async (index, item) => {
|
||||
item = $(item);
|
||||
const title = item.find('td:nth-child(1) > a:nth-child(2)').text();
|
||||
const author = item.find('td:nth-child(2) cite a').text();
|
||||
const date = item.find('td:nth-child(2) em').text();
|
||||
const link = 'https://bbs.zhibo8.cc' + item.find('td:nth-child(1) > a:nth-child(2)').attr('href');
|
||||
|
||||
const single = {
|
||||
title,
|
||||
author,
|
||||
link,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
|
||||
const key = link;
|
||||
const value = await ctx.cache.get(key);
|
||||
if (value) {
|
||||
single.description = value;
|
||||
} else {
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
$('.detail_ent img').each(function() {
|
||||
const $img = $(this);
|
||||
const src = $img.attr('src');
|
||||
$img.attr('src', 'https:' + src);
|
||||
});
|
||||
single.description = $('.detail_ent').html();
|
||||
ctx.cache.set(key, single.description, 12 * 60 * 60);
|
||||
}
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
.get()
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title}—直播吧`,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const link = `https://bbs.zhibo8.cc/forum/topic?tid=${id}`;
|
||||
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const title = $('div.topic-title > h1').text();
|
||||
const list = $('.topic-content .topic-table');
|
||||
|
||||
const out = await Promise.all(
|
||||
list
|
||||
.map(async (index, item) => {
|
||||
item = $(item);
|
||||
const author = item.find('.topic-left > div > a').text();
|
||||
const floor = item.find('p.topic-foot span:nth-child(2)').text();
|
||||
const description = item
|
||||
.find('.detail_ent')
|
||||
.html()
|
||||
.replace(/src="/g, 'src="https:');
|
||||
|
||||
const single = {
|
||||
title: `${floor}:${author}发表了新回复`,
|
||||
author,
|
||||
description,
|
||||
guid: floor,
|
||||
};
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
.get()
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `“${title}”的新回复—直播吧`,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue