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.
feat(route): 轻之国度 文章更新阅读 DIYgod#11848 (DIYgod#13938)
* add router 关于bilibili票务 * bilibili票务基础模板 * add bilibili会员购票务 maintainer * add cookie * doc文档,radar * add 补充内容 * 修改doc条目顺序,优化代码 * fix:修复doc文旦错误,移除作者备注 * fix: delete radar.js中的多余文字 * fix: 修复错误 * 开坑,轻之国度。 * 轻之国度,主体完成 * fix: router.js * 添加文章正文内容 * 文档补全 * cookie可从环境变量赋值 * fix:补充说明 * fix:补充说明 * fix:puppeteer浏览器没有关闭的问题 * fix: 作者名字写错了 * fix: delete tpye in route,modify case * fix: puppeteer change to got * fix:remove collctions and puppeteer * fix: add cookie doc * fix: website can not run beacuse '
- Loading branch information
1 parent
7d96b03
commit 5774a57
Showing
8 changed files
with
99 additions
and
0 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 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,62 @@ | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const config = require('@/config').value; | ||
|
||
module.exports = async (ctx) => { | ||
const baseUrl = 'https://www.lightnovel.us'; | ||
const { type, keywords, security_key = config.lightnovel.cookie } = ctx.params; | ||
const { data: response } = await got({ | ||
method: 'POST', | ||
url: `${baseUrl}/proxy/api/search/search-result`, | ||
headers: { | ||
// 此处是为什么 | ||
'User-Agent': config.trueUA, | ||
}, | ||
json: { | ||
is_encrypted: 0, | ||
platform: 'pc', | ||
client: 'web', | ||
sign: '', | ||
gz: 0, | ||
d: { | ||
q: keywords, | ||
type: 0, | ||
page: 1, | ||
security_key, | ||
}, | ||
}, | ||
}); | ||
const list = response.data.articles | ||
.map((item) => ({ | ||
title: item.title, | ||
link: `${baseUrl}/cn/detail/${item.aid}`, | ||
pubDate: parseDate(item.time), | ||
author: item.author, | ||
})) | ||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 5); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: response } = await got({ | ||
method: 'GET', | ||
url: item.link, | ||
headers: { | ||
'User-Agent': config.trueUA, | ||
}, | ||
}); | ||
|
||
const $ = cheerio.load(response); | ||
item.description = $('#article-main-contents').html(); | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `轻之国度-追踪${keywords}更新-${type} `, | ||
link: baseUrl, | ||
item: items, | ||
}; | ||
}; |
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 = { | ||
'/:keywords/:security_key?': ['nightmare-mio'], | ||
}; |
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 = { | ||
'lightNovel.us': { | ||
_name: '轻之国度', | ||
'.': [ | ||
{ | ||
title: '文章更新阅读', | ||
docs: 'https://docs.rsshub.app/routes/anime#qing-zhi-guo-du', | ||
source: '/', | ||
target: '/lightnovel/:keywords/:security_key', | ||
}, | ||
], | ||
}, | ||
}; |
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('/:keywords/:security_key?', require('./lightNovel')); | ||
}; |
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
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