Skip to content

Commit

Permalink
feat(route): add 连享会 (DIYgod#11067)
Browse files Browse the repository at this point in the history
  • Loading branch information
nczitzk authored Oct 12, 2022
1 parent eba5136 commit ada7037
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 0 deletions.
51 changes: 51 additions & 0 deletions docs/programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,57 @@ GitHub 官方也提供了一些 RSS:

<Route author="huhuhang" example="/lanqiao/questions/2" path="/lanqiao/questions/:id" :paramsDesc="['topic_id 主题 `id` 可在社区板块 URL 中找到']" radar="1" rssbud="1"/>

## 连享会

### 精彩资讯

<Route author="nczitzk" example="/lianxh" path="/lianxh/:category?" :paramsDesc="['分类 id,可在对应分类页 URL 中找到,默认为空,即全部']">

| 分类 | id |
| --------------- | -- |
| 全部 | |
| Stata 入门 | 16 |
| Stata 教程 | 17 |
| 计量专题 | 18 |
| 内生性 - 因果推断 | 19 |
| 面板数据 | 20 |
| 交乘项 - 调节 - 中介 | 21 |
| 结果输出 | 22 |
| 工具软件 | 23 |
| Stata 绘图 | 24 |
| 数据处理 | 25 |
| Stata 程序 | 26 |
| Probit-Logit | 27 |
| 时间序列 | 28 |
| 空间计量 - 网络分析 | 29 |
| Markdown-LaTeX | 30 |
| 论文写作 | 31 |
| 回归分析 | 32 |
| 其它 | 33 |
| 数据分享 | 34 |
| Stata 资源 | 35 |
| 文本分析 - 爬虫 | 36 |
| Python-R-Matlab | 37 |
| IV-GMM | 38 |
| 倍分法 DID | 39 |
| 断点回归 RDD | 40 |
| PSM-Matching | 41 |
| 合成控制法 | 42 |
| Stata 命令 | 43 |
| 专题课程 | 44 |
| 风险管理 | 45 |
| 生存分析 | 46 |
| 机器学习 | 47 |
| 分位数回归 | 48 |
| SFA-DEA - 效率分析 | 49 |
| 答疑 - 板书 | 50 |
| 论文重现 | 51 |
| 最新课程 | 52 |
| 公开课 | 53 |
| Stata33 讲 | 54 |

</Route>

## 洛谷

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

module.exports = async (ctx) => {
const category = ctx.params.category ?? '';

const rootUrl = 'https://www.lianxh.cn';
const currentUrl = `${rootUrl}/blogs${category ? `/${category}` : ''}.html`;

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

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

let items = $('.news-title a')
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30)
.toArray()
.map((item) => {
item = $(item);

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

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

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

item.description = content('#nice').html();
item.pubDate = parseDate(
content('.news-share')
.prev()
.find('span')
.first()
.text()
.match(/(\d+-\d+-\d+)/)[1],
'YYYY-MM-DD'
);

return item;
})
)
);

ctx.state.data = {
title: `连享会 - ${$('.actives').text()}`,
link: currentUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/lianxh/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:category?': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/lianxh/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'lianxh.cn': {
_name: '连享会',
'.': [
{
title: '精彩资讯',
docs: 'https://docs.rsshub.app/programming.html#lian-xiang-hui-jing-cai-zi-xun',
source: ['/blogs.html', '/'],
target: '/lianxh/:category?',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/lianxh/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:category?', require('./index'));
};

0 comments on commit ada7037

Please sign in to comment.