Skip to content

Commit

Permalink
feat(route): add dbaplus社群 (DIYgod#14925)
Browse files Browse the repository at this point in the history
* feat(route): add dbaplus社群

* fix(route): fix dbaplus

* fix(route): fix dbaplus社群

* Update rss.ts

* Update rss.ts

* Update rss.ts

---------

Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
  • Loading branch information
cnkmmk and pull[bot] authored Mar 24, 2024
1 parent 68456e5 commit 2fc3b3a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/routes/dbaplus/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'dbaplus社群',
url: 'dbaplus.cn',
};
48 changes: 48 additions & 0 deletions lib/routes/dbaplus/rss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Route } from '@/types';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import { load } from 'cheerio';

export const route: Route = {
path: '/',
categories: ['programming'],
example: '/dbaplus',
radar: [
{
source: ['dbaplus.cn/'],
},
],
name: '最新文章',
maintainers: ['cnkmmk'],
handler,
url: 'dbaplus.cn/',
};

async function handler() {
const url = 'https://dbaplus.cn';
const response = await got(`${url}/news-9-1.html`);
const $ = load(response.data);

const list = $('div.col-xs-12.col-md-8.pd30 > div.panel.panel-default.categeay > div.panel-body > ul.media-list.clearfix > li.media')
.map((i, e) => {
const element = $(e);
const title = element.find('h3 > a').text();
const link = element.find('h3 > a').attr('href');
const description = element.find('div.mt10.geay').text();
const dateraw = element.find('span.time').text();

return {
title,
description,
link,
pubDate: parseDate(dateraw, 'YYYY年MM月DD日'),
};
})
.get();

return {
title: 'dbaplus社群',
link: url,
item: list,
};
}

0 comments on commit 2fc3b3a

Please sign in to comment.