-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
11 changed files
with
219 additions
and
210 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 was deleted.
Oops, something went wrong.
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,53 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const timezone = require('@/utils/timezone'); | ||
|
||
module.exports = async (ctx) => { | ||
const categoryId = ctx.params.cat; | ||
const link = `https://www.niaogebiji.com/cat/${categoryId}`; | ||
|
||
const response = await got(link); | ||
const $ = cheerio.load(response.data); | ||
const catName = $('h1').text(); | ||
|
||
const articles = $('div.articleBox.clearfix') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
return { | ||
title: item.find('.articleTitle').text().trim(), | ||
description: item.find('.articleContentInner').text().trim(), | ||
author: item.find('.author').text().trim(), | ||
link: new URL(item.find('a').first().attr('href'), link).href, | ||
category: [ | ||
...item | ||
.find('.art_tag') | ||
.toArray() | ||
.map((tag) => $(tag).text().trim()), | ||
catName, | ||
], | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
articles.map((element) => | ||
ctx.cache.tryGet(element.link, async () => { | ||
const response = await got(element.link); | ||
const $ = cheerio.load(response.data); | ||
|
||
element.pubDate = timezone(parseDate($('.writeTime3').text().trim()), 8); | ||
element.description = $('.pc_content').html(); | ||
|
||
return element; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: $('head title').text(), | ||
description: $('head meta[name="description"]').attr('content'), | ||
link, | ||
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,41 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const baseUrl = 'https://www.niaogebiji.com'; | ||
const { data: response } = await got(`${baseUrl}/pc/index/getMoreArticle`); | ||
|
||
if (response.return_code !== '200') { | ||
throw Error(response.return_msg); | ||
} | ||
|
||
const postList = response.return_data.map((item) => ({ | ||
title: item.title, | ||
description: item.summary, | ||
author: item.author, | ||
pubDate: parseDate(item.published_at, 'X'), | ||
updated: parseDate(item.updated_at, 'X'), | ||
category: [item.catname, ...item.tag_list], | ||
link: new URL(item.link, baseUrl).href, | ||
})); | ||
|
||
const result = await Promise.all( | ||
postList.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = cheerio.load(response); | ||
|
||
item.description = $('.pc_content').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: '鸟哥笔记', | ||
link: baseUrl, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
'': ['WenryXu'], | ||
'/': ['WenryXu'], | ||
'/cat/:cat': ['cKotoriKat'], | ||
'/today': ['KotoriK'], | ||
}; |
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,25 @@ | ||
module.exports = { | ||
'niaogebiji.com': { | ||
_name: '鸟哥笔记', | ||
'.': [ | ||
{ | ||
title: '首页', | ||
docs: 'https://docs.rsshub.app/new-media#niao-ge-bi-ji', | ||
source: ['/'], | ||
target: '/niaogebiji', | ||
}, | ||
{ | ||
title: '今日事', | ||
docs: 'https://docs.rsshub.app/new-media#niao-ge-bi-ji', | ||
source: ['/', '/bulletin'], | ||
target: '/niaogebiji', | ||
}, | ||
{ | ||
title: '分类目录', | ||
docs: 'https://docs.rsshub.app/new-media#niao-ge-bi-ji', | ||
source: ['/cat/:cat'], | ||
target: '/niaogebiji/cat/:cat', | ||
}, | ||
], | ||
}, | ||
}; |
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,5 @@ | ||
module.exports = (router) => { | ||
router.get('/', require('./index')); | ||
router.get('/cat/:cat', require('./cat')); | ||
router.get('/today', require('./today')); | ||
}; |
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,34 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const response = await got({ | ||
method: 'post', | ||
url: 'https://www.niaogebiji.com/pc/bulletin/index', | ||
form: { | ||
page: 1, | ||
pub_time: '', | ||
isfromajax: 1, | ||
}, | ||
}); | ||
|
||
if (response.data.return_code !== '200') { | ||
throw Error(response.data.return_msg); | ||
} | ||
|
||
const data = response.data.return_data; | ||
|
||
ctx.state.data = { | ||
title: '鸟哥笔记-今日事', | ||
link: 'https://www.niaogebiji.com/bulletin', | ||
item: data.map((item) => ({ | ||
title: item.title, | ||
description: item.content, | ||
link: item.url, | ||
pubDate: parseDate(item.pub_time, 'X'), | ||
updated: parseDate(item.updated_at, 'X'), | ||
category: item.seo_keywords.split(','), | ||
author: item.user_info.nickname, | ||
})), | ||
}; | ||
}; |
Oops, something went wrong.