From f944cc9a693608f43a21952b83f9919eec1df607 Mon Sep 17 00:00:00 2001
From: Fatpandac <1779196284@qq.com>
Date: Sat, 22 Jan 2022 23:43:25 +0800
Subject: [PATCH] Add(route): add ulapia (#8881)
---
docs/finance.md | 16 +++++++++++
lib/v2/ulapia/index.js | 47 +++++++++++++++++++++++++++++++
lib/v2/ulapia/maintainer.js | 3 ++
lib/v2/ulapia/radar.js | 55 +++++++++++++++++++++++++++++++++++++
lib/v2/ulapia/research.js | 38 +++++++++++++++++++++++++
lib/v2/ulapia/router.js | 4 +++
6 files changed, 163 insertions(+)
create mode 100644 lib/v2/ulapia/index.js
create mode 100644 lib/v2/ulapia/maintainer.js
create mode 100644 lib/v2/ulapia/radar.js
create mode 100644 lib/v2/ulapia/research.js
create mode 100644 lib/v2/ulapia/router.js
diff --git a/docs/finance.md b/docs/finance.md
index db3469ef27..c2c5e4bb18 100644
--- a/docs/finance.md
+++ b/docs/finance.md
@@ -183,6 +183,22 @@ pageClass: routes
+## 乌拉邦
+
+### 最新研报
+
+
+
+### 频道
+
+
+
+| 个股研报 | 行业研报 | 策略研报 | 宏观研报 | 新股研报 | 券商晨报(今日晨报) |
+| :------------: | :---------------: | :---------------: | :------------: | :----------: | :------------------: |
+| stock_research | industry_research | strategy_research | macro_research | ipo_research | brokerage_news |
+
+
+
## 新浪财经
### 新浪财经-国內
diff --git a/lib/v2/ulapia/index.js b/lib/v2/ulapia/index.js
new file mode 100644
index 0000000000..5d078f562c
--- /dev/null
+++ b/lib/v2/ulapia/index.js
@@ -0,0 +1,47 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+
+const rootUrl = 'http://www.ulapia.com';
+
+const titleMap = {
+ brokerage_news: '券商晨报',
+ stock_research: '个股研报',
+ industry_research: '行业研报',
+ strategy_research: '策略研报',
+ macro_research: '宏观研报',
+ ipo_research: 'IPO研报',
+};
+
+const selectorMap = {
+ brokerage_news: 'div.col-md-4',
+ stock_research: 'div.col-md-6',
+ industry_research: 'div.col-md-6',
+ strategy_research: 'div.col-md-6',
+ macro_research: 'div.col-md-6',
+ ipo_research: 'div.col-md-6',
+};
+
+module.exports = async (ctx) => {
+ const category = ctx.params.category ?? 'brokerage_news';
+ const url = `${rootUrl}/reports/${category}`;
+
+ const response = await got.get(url);
+ const $ = cheerio.load(response.data);
+ const items = $(String(selectorMap[category]))
+ .filter((_, item) => $(item).find('img').attr('src'))
+ .map((_, item) => ({
+ title: `${$(item).find('strong').text()} ${$(item).find('h5.mb-1').text()}`,
+ author: $(item).find('div.col.p-8.d-flex.px-3.py-3.flex-column.position-static > div:nth-child(4) > span:nth-child(2)').text(),
+ link: $(item).find('h5.mb-1 > a').attr('href'),
+ description: `
`,
+ pubDate: parseDate($(item).find('div.mb-0.text-muted').last().text().split(':')[1], 'YYYY-MM-DD'),
+ }))
+ .get();
+
+ ctx.state.data = {
+ title: ` ulapia - ${titleMap[category]}`,
+ link: url,
+ item: items,
+ };
+};
diff --git a/lib/v2/ulapia/maintainer.js b/lib/v2/ulapia/maintainer.js
new file mode 100644
index 0000000000..9165f19c6e
--- /dev/null
+++ b/lib/v2/ulapia/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/reports/:category?': ['Fatpandac'],
+};
diff --git a/lib/v2/ulapia/radar.js b/lib/v2/ulapia/radar.js
new file mode 100644
index 0000000000..20c3a2e72e
--- /dev/null
+++ b/lib/v2/ulapia/radar.js
@@ -0,0 +1,55 @@
+module.exports = {
+ 'ulapia.com': {
+ _name: '乌拉邦 ulapia',
+ www: [
+ {
+ title: '今日晨报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-pin-dao',
+ source: ['/'],
+ target: '/ulapia/reports/brokerage_news',
+ },
+ {
+ title: '最新研报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-zui-xin-yan-bao',
+ source: ['/'],
+ target: '/ulapia/research/latest',
+ },
+ {
+ title: '个股研报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-pin-dao',
+ source: ['/reports/stock_research'],
+ target: '/ulapia/reports/stock_research',
+ },
+ {
+ title: '行业研报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-pin-dao',
+ source: ['/reports/industry_research'],
+ target: '/ulapia/reports/industry_research',
+ },
+ {
+ title: '策略研报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-pin-dao',
+ source: ['/reports/strategy_research'],
+ target: '/ulapia/reports/strategy_research',
+ },
+ {
+ title: '宏观研报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-pin-dao',
+ source: ['/reports/macro_research'],
+ target: '/ulapia/reports/macro_research',
+ },
+ {
+ title: '新股研报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-pin-dao',
+ source: ['/reports/ipo_research'],
+ target: '/ulapia/reports/ipo_research',
+ },
+ {
+ title: '券商晨报',
+ docs: 'https://docs.rsshub.app/finance.html#wu-la-bang-pin-dao',
+ source: ['/reports/brokerage_news'],
+ target: '/ulapia/reports/brokerage_news',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/ulapia/research.js b/lib/v2/ulapia/research.js
new file mode 100644
index 0000000000..32a631ec0a
--- /dev/null
+++ b/lib/v2/ulapia/research.js
@@ -0,0 +1,38 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+
+const rootUrl = 'http://www.ulapia.com';
+
+const researchList = ['stock_research', 'industry_research', 'strategy_research', 'macro_research', 'ipo_research'];
+
+module.exports = async (ctx) => {
+ const items = await Promise.all(
+ researchList.map((item) => {
+ const url = `${rootUrl}/reports/${item}`;
+
+ return ctx.cache.tryGet(url, async () => {
+ const response = await got.get(url);
+ const $ = cheerio.load(response.data);
+ const items = $('div.row > div.col-md-6')
+ .slice(0, 6)
+ .map((_, item) => ({
+ title: `${$(item).find('strong').text()} ${$(item).find('h5.mb-1').text()}`,
+ author: $(item).find('div.col.p-8.d-flex.px-3.py-3.flex-column.position-static > div:nth-child(4) > span:nth-child(2)').text(),
+ link: $(item).find('h5.mb-1 > a').attr('href'),
+ description: `
`,
+ pubDate: parseDate($(item).find('div.mb-0.text-muted').last().text().split(':')[1], 'YYYY-MM-DD'),
+ }))
+ .get();
+
+ return items;
+ });
+ })
+ );
+
+ ctx.state.data = {
+ title: 'Ulapia - 最新研报',
+ link: rootUrl,
+ item: items.flat(),
+ };
+};
diff --git a/lib/v2/ulapia/router.js b/lib/v2/ulapia/router.js
new file mode 100644
index 0000000000..d96a171ad4
--- /dev/null
+++ b/lib/v2/ulapia/router.js
@@ -0,0 +1,4 @@
+module.exports = function (router) {
+ router.get('/reports/:category?', require('./index'));
+ router.get('/research/latest', require('./research'));
+};