Skip to content

Commit

Permalink
Merge pull request DIYgod#6599 from nczitzk/feature/6park
Browse files Browse the repository at this point in the history
feat: add 留园网社区分站
  • Loading branch information
NeverBehave authored Jan 11, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 547dd2a + 9a2d372 commit 68989d2
Showing 4 changed files with 118 additions and 1 deletion.
56 changes: 55 additions & 1 deletion docs/new-media.md
Original file line number Diff line number Diff line change
@@ -1347,13 +1347,67 @@ column 为 third 时可选的 category:
### 首页

<Route author="xyqfer" example="/laosiji/feed" path="/laosiji/feed"/>
### 24小时热门

### 24 小时热门

<Route author="xyqfer" example="/laosiji/hot" path="/laosiji/hot"/>

### 节目

<Route author="xyqfer" example="/laosiji/hotshow/128" path="/laosiji/hotshow/:id" :paramsDesc="['节目 id']"/>

## 留园网

### 分站

<Route author="nczitzk" example="/6park" path="/6park/:id?" :paramsDesc="['分站,见下表,默认为史海钩沉']">

| 婚姻家庭 | 魅力时尚 | 女性频道 | 生活百态 | 美食厨房 | 非常影音 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| life9 | life1 | chan10 | life2 | life6 | fr |

| 车迷沙龙 | 游戏天地 | 卡通漫画 | 体坛纵横 | 运动健身 | 电脑前线 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| enter7 | enter3 | enter6 | enter5 | sport | know1 |

| 数码家电 | 旅游风向 | 摄影部落 | 奇珍异宝 | 笑口常开 | 娱乐八卦 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| chan6 | life7 | chan8 | page | enter1 | enter8 |

| 吃喝玩乐 | 文化长廊 | 军事纵横 | 百家论坛 | 科技频道 | 爱子情怀 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| netstar | life10 | nz | other | chan2 | chan5 |

| 健康人生 | 博论天下 | 史海钩沉 | 网际谈兵 | 经济观察 | 谈股论金 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| life5 | bolun | chan1 | military | finance | chan4 |

| 杂论闲侃 | 唯美乐园 | 学习园地 | 命理玄机 | 宠物情缘 | 网络歌坛 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| pk | gz1 | gz2 | gz3 | life8 | chan7 |

| 音乐殿堂 | 情感世界 |
| -------- | -------- |
| enter4 | life3 |

::: tip 提示

酷 18 文档参见 [此处](https://docs.rsshub.app/picture.html#ku-18)

禁忌书屋文档参见 [此处](https://docs.rsshub.app/reading.html#jin-ji-shu-wu)

:::

</Route>

### 精华区

<Route author="nczitzk" example="/6park/chan1/gold" path="/6park/:id/gold" :paramsDesc="['分站,见上表']"/>

### 搜索关键字

<Route author="nczitzk" example="/6park/chan1/keywords/都市" path="/6park/:id/keywords/:keyword?" :paramsDesc="['分站,见上表', '关键字']"/>

## 妈咪帮

<Route author="nczitzk" example="/mamibuy" path="/mamibuy/:caty?/:age?/:sort?" :paramsDesc="['分类,见下表,默认为全分類', '岁数,见下表,默认为不限', '排序,见下表,默认为最新']">
2 changes: 2 additions & 0 deletions docs/picture.md
Original file line number Diff line number Diff line change
@@ -358,6 +358,8 @@ R18 显示

::: tip 提示

留园网文档参见 [此处](https://docs.rsshub.app/new-media.html#liu-yuan-wang)

禁忌书屋文档参见 [此处](https://docs.rsshub.app/reading.html#jin-ji-shu-wu)

:::
3 changes: 3 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
@@ -3790,6 +3790,9 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
// Caixin Latest
router.get('/caixin/latest', require('./routes/caixin/latest'));

// 留园网
router.get('/6park/:id?/:type?/:keyword?', require('./routes/6park/index'));

// 哔嘀影视
router.get('/bde4/:type?/:caty?/:area?/:year?/:order?', require('./routes/bde4/index'));

58 changes: 58 additions & 0 deletions lib/routes/6park/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');

module.exports = async (ctx) => {
const id = ctx.params.id || 'chan1';
const type = ctx.params.type || '';
const keyword = ctx.params.keyword || '';

const rootUrl = 'https://club.6parkbbs.com';
const indexUrl = `${rootUrl}/${id}/index.php`;
const currentUrl = `${indexUrl}${type === '' || keyword === '' ? '' : type === 'gold' ? '?app=forum&act=gold' : `?action=search&act=threadsearch&app=forum&${type}=${keyword}&submit=${type === 'type' ? '查询' : '栏目搜索'}`}`;

const response = await got({
method: 'get',
url: currentUrl,
});

const $ = cheerio.load(response.data);

const list = $('#d_list ul li, #thread_list li, .t_l .t_subject')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a').eq(0);
return {
link: `${rootUrl}/${id}/${a.attr('href')}`,
};
})
.get();

const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);

item.title = content('title').text().replace(' -6park.com', '');
item.author = detailResponse.data.match(/送交者: .*>(.*)<.*\[/)[1];
item.pubDate = new Date(detailResponse.data.match(/于 (.*) 已读/)[1]).toUTCString();
item.description = content('pre')
.html()
.replace(/<font color="#E6E6DD">6park.com<\/font>/g, '');

return item;
})
)
);

ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};

0 comments on commit 68989d2

Please sign in to comment.