fix: update csdn url (#17504)

* fix: update csdn url

* catch detail error

* fix: add back maintainers

---------
This commit is contained in:
Stephen Zhou 2024-11-09 03:31:48 +08:00 committed by GitHub
parent 3ea381e7db
commit a267675d8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 13 deletions

View File

@ -23,35 +23,39 @@ export const route: Route = {
},
],
name: 'User Feed',
maintainers: [],
maintainers: ['Jkker'],
handler,
};
async function handler(ctx) {
const user = ctx.req.param('user');
const rootUrl = 'https://blog.csdn.net';
const rootUrl = 'https://rss.csdn.net';
const blogUrl = `${rootUrl}/${user}`;
const rssUrl = blogUrl + '/rss/list';
const rssUrl = blogUrl + '/rss/map';
const feed = await rssParser.parseURL(rssUrl);
const items = await Promise.all(
feed.items.map((item) =>
cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
});
try {
const response = await got({
method: 'get',
url: item.link,
});
const $ = load(response.data);
const $ = load(response.data);
const description = $('#content_views').html();
const description = $('#content_views').html();
return {
...item,
description,
};
return {
...item,
description,
};
} catch {
return item;
}
})
)
);