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 HKJunkCall資訊中心 #8405

Merged
merged 1 commit into from
Nov 27, 2021
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 @@ -364,6 +364,12 @@ Tag

</Route>

## HKJunkCall 資訊中心

### 近期資訊

<Route author="nczitzk" example="/hkjunkcall" path="/hkjunkcall" />

## iDaily 每日环球视野

### 今日 Timeline
Expand Down
53 changes: 53 additions & 0 deletions lib/v2/hkjunkcall/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const rootUrl = 'https://hkjunkcall.com';
const currentUrl = `${rootUrl}/cdpushdash.asp`;

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

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

const list = $('.hh15')
.map((_, item) => {
item = $(item).parent();

return {
title: item.text(),
link: item.attr('href'),
};
})
.get();

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

const content = cheerio.load(detailResponse.data);

content('.card').find('div, h2').remove();

item.guid = item.link.split('/').pop();
item.description = content('.card').html();
item.pubDate = parseDate(detailResponse.data.match(/<br \/>(\d+-\d+-\d+)<\/div><\/a>/)[1]);

return item;
})
)
);

ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/hkjunkcall/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/hkjunkcall/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'hkjunkcall.com': {
_name: 'HKJunkCall資訊中心',
'.': [
{
title: '近期資訊',
docs: 'https://docs.rsshub.app/new-media.html#hkjunkcall-zi-xun-zhong-xin-jin-qi-zi-xun',
source: ['/'],
target: '/hkjunkcall',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/hkjunkcall/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/', require('./index'));
};