-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ethan Shen
authored
Nov 27, 2021
1 parent
62d0e09
commit 713253b
Showing
6 changed files
with
70 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/rule': ['nczitzk'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'szse.cn': { | ||
_name: '深圳证券交易所', | ||
'.': [ | ||
{ | ||
title: '最新规则', | ||
docs: 'https://docs.rsshub.app/other.html#shen-zhen-zheng-quan-jiao-yi-suo-zui-xin-gui-ze', | ||
source: ['/lawrules/rule/new', '/'], | ||
target: '/szse/rule', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (router) { | ||
router.get('/rule', require('./rule')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const rootUrl = 'http://www.szse.cn'; | ||
const currentUrl = `${rootUrl}/api/search/content`; | ||
|
||
const response = await got({ | ||
method: 'post', | ||
url: currentUrl, | ||
form: { | ||
keyword: '', | ||
time: 0, | ||
range: 'title', | ||
'channelCode[]': 'szserulesAllRulesBuss', | ||
currentPage: 1, | ||
pageSize: 30, | ||
scope: 0, | ||
}, | ||
}); | ||
|
||
const list = response.data.data.map((item) => ({ | ||
title: item.doctitle, | ||
link: item.docpuburl, | ||
pubDate: parseDate(item.docpubtime), | ||
})); | ||
|
||
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); | ||
|
||
item.description = content('#desContent').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: '最新规则 - 深圳证券交易所', | ||
link: `${rootUrl}/lawrules/rule/new`, | ||
item: items, | ||
}; | ||
}; |