mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 13:39:35 +08:00
optimize directory structure
This commit is contained in:
36
lib/routes/blogread/newest.js
Normal file
36
lib/routes/blogread/newest.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'http://blogread.cn/news/newest.php';
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const resultItem = $('.media')
|
||||
.map((index, elem) => {
|
||||
elem = $(elem);
|
||||
const $link = elem.find('dt a');
|
||||
|
||||
return {
|
||||
title: $link.text(),
|
||||
description: elem
|
||||
.find('dd')
|
||||
.eq(0)
|
||||
.text(),
|
||||
link: $link.attr('href'),
|
||||
author: elem
|
||||
.find('.small a')
|
||||
.eq(0)
|
||||
.text(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '技术头条',
|
||||
link: url,
|
||||
item: resultItem,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user