-
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
Showing
6 changed files
with
68 additions
and
31 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,47 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const link = 'https://www.hex-rays.com/blog/'; | ||
const response = await got.get(link); | ||
const $ = cheerio.load(response.data); | ||
|
||
const list = $('.post-list-container') | ||
.map((_, ele) => ({ | ||
title: $('h3 > a', ele).text(), | ||
link: $('h3 > a', ele).attr('href'), | ||
pubDate: parseDate($('.post-meta:nth-of-type(1)', ele).first().text().trim().replace('Posted on:', '')), | ||
author: $('.post-meta:nth-of-type(2)', ele).first().text().replace('By:', '').trim(), | ||
})) | ||
.get(); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got.get(item.link); | ||
const content = cheerio.load(detailResponse.data); | ||
|
||
item.category = ( | ||
content('.category-link') | ||
.toArray() | ||
.map((e) => $(e).text()) + | ||
',' + | ||
content('.tag-link') | ||
.toArray() | ||
.map((e) => $(e).text()) | ||
).split(','); | ||
|
||
item.description = content('.post-content').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: 'Hex-Rays Blog', | ||
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,3 @@ | ||
module.exports = { | ||
'/news': ['hellodword ', 'TonyRL'], | ||
}; |
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 = { | ||
'hex-rays.com': { | ||
_name: 'Hex-Rays', | ||
'.': [ | ||
{ | ||
title: 'Hex-Rays News', | ||
docs: 'https://docs.rsshub.app/programming.html#hex-rays', | ||
source: ['/', '/blog'], | ||
target: '/hex-rays/news', | ||
}, | ||
], | ||
}, | ||
}; |
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('/news', require('./index')); | ||
}; |