Skip to content

Commit

Permalink
fix: update csdn url (#17504)
Browse files Browse the repository at this point in the history
* fix: update csdn url

* catch detail error

* fix: add back maintainers

---------
  • Loading branch information
hyoban authored Nov 8, 2024
1 parent 3ea381e commit a267675
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/routes/csdn/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
})
)
);
Expand Down

0 comments on commit a267675

Please sign in to comment.