mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
@@ -11,15 +11,21 @@ module.exports = async (ctx) => {
|
||||
|
||||
const list = $('a.list-group-item')
|
||||
.slice(0, 10)
|
||||
.filter((i, e) => $(e).find('h4.media-heading i').length === 0)
|
||||
.map(function() {
|
||||
const info = {
|
||||
title: $(this)
|
||||
.find('h4.media-heading')
|
||||
.text()
|
||||
.trim(),
|
||||
author: $(this)
|
||||
.find('.text-500')
|
||||
.text(),
|
||||
link: $(this).attr('href'),
|
||||
date: $(this)
|
||||
.find('p.pull-right.media-date strong')
|
||||
.text(),
|
||||
.text()
|
||||
.trim(),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
@@ -27,8 +33,6 @@ module.exports = async (ctx) => {
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
const title = info.title;
|
||||
const date = info.date;
|
||||
const itemUrl = url.resolve(host, info.link);
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
@@ -47,19 +51,22 @@ module.exports = async (ctx) => {
|
||||
.trim();
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
title: info.title,
|
||||
author: info.author,
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
description,
|
||||
pubDate: new Date(info.date).toUTCString(),
|
||||
};
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'leetcode文章',
|
||||
link: link,
|
||||
title: 'LeetCode Articles',
|
||||
description: 'LeetCode Articles, the only official solutions you will find.',
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user