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