mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 贴吧用户发帖 (#6072)
This commit is contained in:
@@ -439,6 +439,12 @@ pageClass: routes
|
||||
|
||||
<Route author="u3u" example="/tieba/post/lz/5853240586" path="/tieba/post/lz/:id" :paramsDesc="['帖子 ID']"/>
|
||||
|
||||
### 用户帖子
|
||||
|
||||
<Route author="humpylin" example="/tieba/user/斗鱼游戏君" path="/tieba/user/:uid" :paramsDesc="['用户 ID']" />
|
||||
|
||||
用户 ID 可以通过打开用户的主页后查看地址栏的 `un` 字段来获取。
|
||||
|
||||
## 万维读者
|
||||
|
||||
### 焦点新闻
|
||||
|
||||
@@ -113,6 +113,7 @@ router.get('/tieba/forum/:kw', require('./routes/tieba/forum'));
|
||||
router.get('/tieba/forum/good/:kw/:cid?', require('./routes/tieba/forum'));
|
||||
router.get('/tieba/post/:id', require('./routes/tieba/post'));
|
||||
router.get('/tieba/post/lz/:id', require('./routes/tieba/post'));
|
||||
router.get('/tieba/user/:uid', require('./routes/tieba/user'));
|
||||
|
||||
// 网易云音乐
|
||||
router.get('/ncm/playlist/:id', require('./routes/ncm/playlist'));
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.uid;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://tieba.baidu.com/home/main?un=${uid}`,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const name = $('span.userinfo_username').text();
|
||||
const list = $('div.n_right.clearfix');
|
||||
let imgurl;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} 的贴吧`,
|
||||
link: `https://tieba.baidu.com/home/main?un=${uid}`,
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item).find('.n_contain');
|
||||
imgurl = item.find('ul.n_media.clearfix img').attr('original');
|
||||
return {
|
||||
title: item.find('div.thread_name a').attr('title'),
|
||||
pubDate: item.parent().find('div .n_post_time').text(),
|
||||
description: `${item.find('div.n_txt').text()}<br><img src="${imgurl}">`,
|
||||
link: item.find('div.thread_name a').attr('href'),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user