fix(route): xiaohongshu throw captcha error
This commit is contained in:
parent
4f44368056
commit
c43cd4a4a2
|
|
@ -7,7 +7,12 @@ module.exports = async (ctx) => {
|
|||
const category = ctx.params.category;
|
||||
const url = `https://www.xiaohongshu.com/user/profile/${userId}`;
|
||||
|
||||
const main = await getContent(url, ctx.cache);
|
||||
let main;
|
||||
try {
|
||||
main = await getContent(url, ctx.cache);
|
||||
} catch (e) {
|
||||
throw Error('滑块验证');
|
||||
}
|
||||
const userDetail = main.userDetail;
|
||||
const description = `${userDetail.nickname} • 小红书 / RED`;
|
||||
if (category === 'notes') {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ const getContent = (url, cache) =>
|
|||
page.on('request', (request) => {
|
||||
request.resourceType() === 'document' || request.resourceType() === 'script' || request.resourceType() === 'xhr' ? request.continue() : request.abort();
|
||||
});
|
||||
page.on('response', (response) => {
|
||||
if (response.url().includes('captcha.fengkongcloud.cn')) {
|
||||
page.close();
|
||||
throw Error('滑块验证');
|
||||
}
|
||||
});
|
||||
await page.goto(url);
|
||||
await page.waitForSelector('.pc-container');
|
||||
const initialSsrState = await page.evaluate(() => window.__INITIAL_SSR_STATE__);
|
||||
|
|
|
|||
Loading…
Reference in New Issue