forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
217 additions
and
1 deletion.
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 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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./lib/*"] | ||
} | ||
}, | ||
"include": ["./lib/**/*"] | ||
} |
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 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,74 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const dayjs = require('dayjs'); | ||
const customParseFormat = require('dayjs/plugin/customParseFormat'); | ||
|
||
dayjs.extend(customParseFormat); | ||
|
||
const typeMap = { | ||
0: '9004748', | ||
1: '9004749', | ||
2: '9213612', | ||
3: '8314815', | ||
4: '9222707', | ||
}; | ||
|
||
/** | ||
* | ||
* @param ctx {import('koa').Context} | ||
*/ | ||
module.exports = async (ctx) => { | ||
const type = ctx.params.type; | ||
const url = `https://help.aliyun.com/noticelist/${typeMap[type] || typeMap[0]}.html`; | ||
const response = await got({ method: 'get', url }); | ||
const $ = cheerio.load(response.data); | ||
const list = $('ul > li.y-clear') | ||
.map((i, e) => { | ||
const element = $(e); | ||
const title = element | ||
.find('a') | ||
.text() | ||
.trim(); | ||
const link = | ||
'https://help.aliyun.com' + | ||
element | ||
.find('a') | ||
.attr('href') | ||
.trim(); | ||
const date = element.find('.y-right').text(); | ||
const pubDate = dayjs(`${date} +0800`, 'YYYY-MM-DDHH:mm:ss ZZ'); | ||
return { | ||
title: title, | ||
description: '', | ||
link: link, | ||
pubDate: pubDate.toString(), | ||
}; | ||
}) | ||
.get(); | ||
|
||
const result = await Promise.all( | ||
list.map(async (item) => { | ||
const link = item.link; | ||
|
||
const cache = await ctx.cache.get(link); | ||
if (cache) { | ||
return Promise.resolve(JSON.parse(cache)); | ||
} | ||
|
||
const itemReponse = await got.get(link); | ||
const itemElement = cheerio.load(itemReponse.data); | ||
item.description = itemElement('#se-knowledge').html(); | ||
|
||
ctx.cache.set(link, JSON.stringify(item)); | ||
return Promise.resolve(item); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: $('title') | ||
.text() | ||
.trim(), | ||
link: url, | ||
item: result, | ||
}; | ||
}; |
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 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 |
---|---|---|
|
@@ -988,6 +988,13 @@ | |
dependencies: | ||
defer-to-connect "^1.0.1" | ||
|
||
"@types/accepts@*": | ||
version "1.3.5" | ||
resolved "https://registry.yarnpkg.com/@types/accepts/-/accepts-1.3.5.tgz#c34bec115cfc746e04fe5a059df4ce7e7b391575" | ||
integrity sha512-jOdnI/3qTpHABjM5cx1Hc0sKsPoYCp+DP/GJRGtDlPd7fiV9oXGGIcjW/ZOxLIvjGz8MA+uMZI9metHlgqbgwQ== | ||
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/babel__core@^7.1.0": | ||
version "7.1.2" | ||
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.2.tgz#608c74f55928033fce18b99b213c16be4b3d114f" | ||
|
@@ -1021,11 +1028,60 @@ | |
dependencies: | ||
"@babel/types" "^7.3.0" | ||
|
||
"@types/body-parser@*": | ||
version "1.17.1" | ||
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.17.1.tgz#18fcf61768fb5c30ccc508c21d6fd2e8b3bf7897" | ||
integrity sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w== | ||
dependencies: | ||
"@types/connect" "*" | ||
"@types/node" "*" | ||
|
||
"@types/[email protected]": | ||
version "0.22.13" | ||
resolved "https://registry.yarnpkg.com/@types/cheerio/-/cheerio-0.22.13.tgz#5eecda091a24514185dcba99eda77e62bf6523e6" | ||
integrity sha512-OZd7dCUOUkiTorf97vJKwZnSja/DmHfuBAroe1kREZZTCf/tlFecwHhsOos3uVHxeKGZDwzolIrCUApClkdLuA== | ||
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/connect@*": | ||
version "3.4.32" | ||
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.32.tgz#aa0e9616b9435ccad02bc52b5b454ffc2c70ba28" | ||
integrity sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg== | ||
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/cookies@*": | ||
version "0.7.2" | ||
resolved "https://registry.yarnpkg.com/@types/cookies/-/cookies-0.7.2.tgz#5e0560d46ed9998082dce799af1058dd6a49780a" | ||
integrity sha512-jnihWgshWystcJKrz8C9hV+Ot9lqOUyAh2RF+o3BEo6K6AS2l4zYCb9GYaBuZ3C6Il59uIGqpE3HvCun4KKeJA== | ||
dependencies: | ||
"@types/connect" "*" | ||
"@types/express" "*" | ||
"@types/keygrip" "*" | ||
"@types/node" "*" | ||
|
||
"@types/events@*": | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" | ||
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== | ||
|
||
"@types/express-serve-static-core@*": | ||
version "4.16.9" | ||
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.16.9.tgz#69e00643b0819b024bdede95ced3ff239bb54558" | ||
integrity sha512-GqpaVWR0DM8FnRUJYKlWgyARoBUAVfRIeVDZQKOttLFp5SmhhF9YFIYeTPwMd/AXfxlP7xVO2dj1fGu0Q+krKQ== | ||
dependencies: | ||
"@types/node" "*" | ||
"@types/range-parser" "*" | ||
|
||
"@types/express@*": | ||
version "4.17.1" | ||
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.1.tgz#4cf7849ae3b47125a567dfee18bfca4254b88c5c" | ||
integrity sha512-VfH/XCP0QbQk5B5puLqTLEeFgR8lfCJHZJKkInZ9mkYd+u8byX0kztXEQxEk4wZXJs8HI+7km2ALXjn4YKcX9w== | ||
dependencies: | ||
"@types/body-parser" "*" | ||
"@types/express-serve-static-core" "*" | ||
"@types/serve-static" "*" | ||
|
||
"@types/glob@^7.1.1": | ||
version "7.1.1" | ||
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" | ||
|
@@ -1035,6 +1091,20 @@ | |
"@types/minimatch" "*" | ||
"@types/node" "*" | ||
|
||
"@types/[email protected]": | ||
version "9.6.7" | ||
resolved "https://registry.yarnpkg.com/@types/got/-/got-9.6.7.tgz#33d84c60cba83e3c904634a1ea7ea81d1549bea6" | ||
integrity sha512-LMc2ja42bQorKpBxf38ZBPdT3FhYL0lyAqnZBo5vAPCtobYa8AiHwSLH5zDvR19r2Pr5Ojar3hT/QLLb2SoPYA== | ||
dependencies: | ||
"@types/node" "*" | ||
"@types/tough-cookie" "*" | ||
form-data "^2.5.0" | ||
|
||
"@types/http-assert@*": | ||
version "1.5.1" | ||
resolved "https://registry.yarnpkg.com/@types/http-assert/-/http-assert-1.5.1.tgz#d775e93630c2469c2f980fc27e3143240335db3b" | ||
integrity sha512-PGAK759pxyfXE78NbKxyfRcWYA/KwW17X290cNev/qAsn9eQIxkH4shoNBafH37wewhDG/0p1cHPbK6+SzZjWQ== | ||
|
||
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff" | ||
|
@@ -1055,6 +1125,35 @@ | |
"@types/istanbul-lib-coverage" "*" | ||
"@types/istanbul-lib-report" "*" | ||
|
||
"@types/keygrip@*": | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/@types/keygrip/-/keygrip-1.0.1.tgz#ff540462d2fb4d0a88441ceaf27d287b01c3d878" | ||
integrity sha1-/1QEYtL7TQqIRBzq8n0oewHD2Hg= | ||
|
||
"@types/koa-compose@*": | ||
version "3.2.4" | ||
resolved "https://registry.yarnpkg.com/@types/koa-compose/-/koa-compose-3.2.4.tgz#76a461634a59c3e13449831708bb9b355fb1548e" | ||
integrity sha512-ioou0rxkuWL+yBQYsHUQAzRTfVxAg8Y2VfMftU+Y3RA03/MzuFL0x/M2sXXj3PkfnENbHsjeHR1aMdezLYpTeA== | ||
dependencies: | ||
"@types/koa" "*" | ||
|
||
"@types/koa@*", "@types/[email protected]": | ||
version "2.0.49" | ||
resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.0.49.tgz#8ffc2ddbdd715a2c392a218c67e116cb07007234" | ||
integrity sha512-WQWpCH8O4Dslk8IcXfazff40aM1jXX7BQRbADIj/fKozVPu76P/wQE4sRe2SCWMn8yNkOcare2MkDrnZqLMkPQ== | ||
dependencies: | ||
"@types/accepts" "*" | ||
"@types/cookies" "*" | ||
"@types/http-assert" "*" | ||
"@types/keygrip" "*" | ||
"@types/koa-compose" "*" | ||
"@types/node" "*" | ||
|
||
"@types/mime@*": | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d" | ||
integrity sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw== | ||
|
||
"@types/minimatch@*": | ||
version "3.0.3" | ||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" | ||
|
@@ -1070,11 +1169,29 @@ | |
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8" | ||
integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw== | ||
|
||
"@types/range-parser@*": | ||
version "1.2.3" | ||
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c" | ||
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA== | ||
|
||
"@types/serve-static@*": | ||
version "1.13.3" | ||
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.3.tgz#eb7e1c41c4468272557e897e9171ded5e2ded9d1" | ||
integrity sha512-oprSwp094zOglVrXdlo/4bAHtKTAxX6VT8FOZlBKrmyLbNvE1zxZyJ6yikMVtHIvwP45+ZQGJn+FdXGKTozq0g== | ||
dependencies: | ||
"@types/express-serve-static-core" "*" | ||
"@types/mime" "*" | ||
|
||
"@types/stack-utils@^1.0.1": | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" | ||
integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== | ||
|
||
"@types/tough-cookie@*": | ||
version "2.3.5" | ||
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.5.tgz#9da44ed75571999b65c37b60c9b2b88db54c585d" | ||
integrity sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg== | ||
|
||
"@types/yargs-parser@*": | ||
version "13.0.0" | ||
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-13.0.0.tgz#453743c5bbf9f1bed61d959baab5b06be029b2d0" | ||
|
@@ -4463,7 +4580,7 @@ forever-agent@~0.6.1: | |
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" | ||
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= | ||
|
||
[email protected], form-data@^2.3.1: | ||
[email protected], form-data@^2.3.1, form-data@^2.5.0: | ||
version "2.5.1" | ||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.1.tgz#f2cbec57b5e59e23716e128fe44d4e5dd23895f4" | ||
integrity sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA== | ||
|