Skip to content

Commit

Permalink
fix(route/xueqiu): mark anti-crawler and improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoyu committed Dec 17, 2024
1 parent 751cd2e commit 4bec9ed
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/routes/xueqiu/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const route: Route = {
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
Expand All @@ -25,14 +25,19 @@ export const route: Route = {
},
],
name: '用户专栏',
maintainers: ['TonyRL'],
maintainers: ['TonyRL', 'pseudoyu'],
handler,
};

async function handler(ctx) {
const id = ctx.req.param('id');
const pageUrl = `${baseUrl}/${id}/column`;

// Get cookie first
await got(baseUrl, {
cookieJar,
});

const pageData = await got(pageUrl, {
cookieJar,
});
Expand All @@ -49,6 +54,10 @@ async function handler(ctx) {
},
});

if (!data.list) {
throw new Error('Error occurred, please refresh the page or try again after logging back into your account');
}

const items = data.list.map((item) => ({
title: item.title,
description: item.description,
Expand Down

0 comments on commit 4bec9ed

Please sign in to comment.