Skip to content

Commit

Permalink
feat(tieba): add boutique post filter (DIYgod#270)
Browse files Browse the repository at this point in the history
* feat(tieba): add boutique post filter

usage: `/tieba/forum/good/:kw/:cid?`

* style(bilibili): eslint --fix

* docs(tieba): add boutique post usage

* docs(tieba): add support list and sorting

The purpose of sorting is to put social types together

* docs(vuepress): sorting is also required in ' vuepress ' documents

* fix(bilibili): type conversions
  • Loading branch information
u3u authored and DIYgod committed Jun 4, 2018
1 parent 7f3fb1e commit db60567
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 22 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 微博
- 博主
- 关键词
- 贴吧
- 帖子列表
- 精品帖子
- 即刻
- 主题
- 用户动态
Expand All @@ -58,8 +61,6 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 自如
- 房源
- 快递
- 贴吧
- 帖子列表
- 妹子图
- 首页(最新)
- 分类
Expand Down
32 changes: 22 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,28 @@ order: 排序方式,live_time 开播时间,online 人气

参数: keyword,你想订阅的微博关键词

## 贴吧

### 帖子列表

举例: [https://rsshub.app/tieba/forum/女图](https://rsshub.app/tieba/forum/女图)

路由: `/tieba/forum/:kw`

参数: `kw`,吧名

### 精品帖子

举例: [https://rsshub.app/tieba/forum/good/女图](https://rsshub.app/tieba/forum/good/女图)

路由: `/tieba/forum/good/:kw/:cid?`

参数:

`kw`: 吧名

`cid`: 精品分类,如果不传 `cid` 则获取全部分类

## 即刻

### 主题-精选
Expand Down Expand Up @@ -539,16 +561,6 @@ company: 快递公司代码,参考 [API URL 所支持的快递公司及参数

number: 快递单号

## 贴吧

### 帖子列表

举例: [https://rsshub.app/tieba/forum/女图](https://rsshub.app/tieba/forum/女图)

路由: `/tieba/forum/:kw`

参数: kw,吧名

## 妹子图

::: warning 注意
Expand Down
1 change: 1 addition & 0 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ router.get('/zhihu/daily', require('./routes/zhihu/daily'));

// 贴吧
router.get('/tieba/forum/:kw', require('./routes/tieba/forum'));
router.get('/tieba/forum/good/:kw/:cid?', require('./routes/tieba/forum'));

// 妹子图
router.get('/mzitu', require('./routes/mzitu/category'));
Expand Down
12 changes: 6 additions & 6 deletions routes/bilibili/blackboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ const config = require('../../config');
module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: `https://www.bilibili.com/activity/page/list?plat=1,2,3`,
url: 'https://www.bilibili.com/activity/page/list?plat=1,2,3',
headers: {
'User-Agent': config.ua,
Referer: `https://www.bilibili.com/blackboard/topic_list.html`,
Referer: 'https://www.bilibili.com/blackboard/topic_list.html',
},
});

const data = response.data.data.list;

ctx.state.data = {
title: `bilibili 话题列表`,
link: `https://www.bilibili.com/blackboard/topic_list.html#/`,
description: `bilibili 话题列表`,
title: 'bilibili 话题列表',
link: 'https://www.bilibili.com/blackboard/topic_list.html#/',
description: 'bilibili 话题列表',
item: data
.filter(function(item, index, array) {
//由于某些话题在不同平台上是同时分开发布的,会产生重复,在这里去除
// 由于某些话题在不同平台上是同时分开发布的,会产生重复,在这里去除
return !index || item.name !== array[index - 1].name;
})
.map((item) => ({
Expand Down
2 changes: 1 addition & 1 deletion routes/bilibili/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {
if (nameResponse && nameResponse.data && nameResponse.data.data && nameResponse.data.data.archive) {
nameResponse.data.data.archive.forEach((item) => {
// noinspection EqualityComparisonWithCoercionJS
if (fid == item.fid) {
if (fid === item.fid.toString()) {
name = item.name;
}
});
Expand Down
10 changes: 7 additions & 3 deletions routes/tieba/forum.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const qs = require('querystring');
const axios = require('../../utils/axios');
const config = require('../../config');

function isNormalTime(time) {
Expand Down Expand Up @@ -32,13 +33,16 @@ function getPubDate(time) {
}

module.exports = async (ctx) => {
const { kw } = ctx.params;
const { kw, cid } = ctx.params;

// PC端:https://tieba.baidu.com/f?kw=${encodeURIComponent(kw)}
// 移动端接口:https://tieba.baidu.com/mo/q/m?kw=${encodeURIComponent(kw)}&lp=5024&forum_recommend=1&lm=0&cid=0&has_url_param=1&pn=0&is_ajax=1
const params = { kw: encodeURIComponent(kw) };
ctx._matchedRoute.includes('good') && (params.tab = 'good');
cid && (params.cid = cid);
const { data } = await axios({
method: 'get',
url: `https://tieba.baidu.com/f?kw=${encodeURIComponent(kw)}`,
url: `https://tieba.baidu.com/f?${qs.stringify(params)}`,
headers: {
'User-Agent': config.ua,
Referer: 'https://tieba.baidu.com/',
Expand Down

0 comments on commit db60567

Please sign in to comment.