Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route): add wanqu #12166

Merged
merged 3 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/new-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -3812,6 +3812,12 @@ column 为 third 时可选的 category:

<Route author="shuiRong" example="/wainao-reads/all-articles" path="/wainao-reads/all-articles" />

## 湾区日报

### 最新推荐

<Route author="Fatpandac" example="/wanqu/news" path="/wanqu/news" radar="1" />
Fatpandac marked this conversation as resolved.
Show resolved Hide resolved

## 晚点 LatePost

### 报道
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/wanqu/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/news': ['Fatpandac'],
};
26 changes: 26 additions & 0 deletions lib/v2/wanqu/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const rootUrl = 'https://www.wanqu.co';
const currentUrl = rootUrl;

const response = await got(currentUrl);

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

const items = $('div.mb-4')
.toArray()
.map((item) => ({
title: $(item).text(),
link: $(item).find('a').attr('href'),
pubDate: parseDate($(item).find('i.text-helper-color.mr-4').text()),
}));

ctx.state.data = {
title: '湾区日报 - 最新推荐',
link: currentUrl,
item: items,
};
};
13 changes: 13 additions & 0 deletions lib/v2/wanqu/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'wanqu.co': {
_name: '湾区日报',
'.': [
{
title: '最新推荐',
docs: 'https://docs.rsshub.app/new-media.html#wan-qu-ri-bao',
source: ['/'],
target: '/wanqu/news',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/wanqu/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news', require('./news'));
};