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.
Merge pull request #970 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
17 changed files
with
215 additions
and
162 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,24 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10; | ||
const rootUrl = `https://www.nasachina.cn/wp-json/wp/v2/posts?categories=2&per_page=${limit}`; | ||
const { data } = await got({ | ||
method: 'get', | ||
url: rootUrl, | ||
}); | ||
|
||
const items = data.map((item) => ({ | ||
title: item.title.rendered, | ||
description: item.content.rendered, | ||
pubDate: parseDate(item.date_gmt), | ||
link: item.link, | ||
})); | ||
|
||
ctx.state.data = { | ||
title: 'NASA中文 - 天文·每日一图', | ||
link: 'https://www.nasachina.cn/nasa-image-of-the-day', | ||
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,51 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10; | ||
const rootUrl = 'http://sprite.phys.ncku.edu.tw/astrolab/mirrors/apod/archivepix.html'; | ||
const response = await got({ | ||
method: 'get', | ||
url: rootUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
const list = $('body > b > a') | ||
.slice(0, limit) | ||
.map((_, el) => ({ | ||
title: $(el).text(), | ||
link: `http://sprite.phys.ncku.edu.tw/astrolab/mirrors/apod/${$(el).attr('href')}`, | ||
})) | ||
.get(); | ||
|
||
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); | ||
|
||
const description = `<img src="${content('img').attr('src')}"> <br> ${content('body > center').eq(1).html()} <br> ${content('body > p').eq(0).html()}`; | ||
const pubDate = parseDate(item.link.slice(-11, -5), 'YYMMDD'); | ||
|
||
const single = { | ||
title: item.title, | ||
description, | ||
pubDate, | ||
link: item.link, | ||
}; | ||
return single; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: 'NASA 每日一天文圖 (成大物理分站) ', | ||
link: rootUrl, | ||
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,51 @@ | ||
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 limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10; | ||
const rootUrl = 'https://apod.nasa.gov/apod/archivepix.html'; | ||
const response = await got({ | ||
method: 'get', | ||
url: rootUrl, | ||
}); | ||
const $ = cheerio.load(response.data); | ||
|
||
const list = $('body > b > a') | ||
.slice(0, limit) | ||
.map((_, el) => ({ | ||
title: $(el).text(), | ||
link: `https://apod.nasa.gov/apod/${$(el).attr('href')}`, | ||
})) | ||
.get(); | ||
|
||
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); | ||
|
||
const description = `<img src="${content('img').attr('src')}"> <br> ${content('body > center').eq(1).html()} <br> ${content('body > p').eq(0).html()}`; | ||
const pubDate = timezone(parseDate(item.link.slice(-11, -5), 'YYMMDD'), -5); | ||
|
||
const single = { | ||
title: item.title, | ||
description, | ||
pubDate, | ||
link: item.link, | ||
}; | ||
return single; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: 'NASA Astronomy Picture of the Day', | ||
link: rootUrl, | ||
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,5 @@ | ||
module.exports = { | ||
'/apod': ['nczitzk', 'williamgateszhao'], | ||
'/apod-ncku': ['nczitzk', 'williamgateszhao'], | ||
'/apod-cn': ['nczitzk', 'williamgateszhao'], | ||
}; |
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,22 @@ | ||
module.exports = { | ||
'nasa.gov': { | ||
_name: 'NASA 每日天文图片', | ||
apod: [ | ||
{ | ||
title: 'NASA', | ||
docs: 'https://docs.rsshub.app/picture.html#nasa-mei-ri-tian-wen-tu-pian', | ||
target: '/nasa/apod', | ||
}, | ||
{ | ||
title: '台湾成功大学镜像', | ||
docs: 'https://docs.rsshub.app/picture.html#nasa-mei-ri-tian-wen-tu-pian', | ||
target: '/nasa/apod-ncku', | ||
}, | ||
{ | ||
title: 'NASA 中文', | ||
docs: 'https://docs.rsshub.app/picture.html#nasa-mei-ri-tian-wen-tu-pian', | ||
target: '/nasa/apod-cn', | ||
}, | ||
], | ||
}, | ||
}; |
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('/apod', require('./apod')); | ||
router.get('/apod-ncku', require('./apod-ncku')); | ||
router.get('/apod-cn', require('./apod-cn')); | ||
}; |
Oops, something went wrong.
164c040
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsshub-master – ./
rsshub-master-auto-bot-ty.vercel.app
rsshub-master.vercel.app
rsshub-master-git-master-auto-bot-ty.vercel.app