{"record":{"id":"f3d84dd735ac20d5","repo":"jackwener/OpenCLI","slug":"trip-com-is-asking-for-a-verification-complete-it-f3d84d","errorCode":null,"errorMessage":"Trip.com is asking for a verification; complete it in your browser session and retry","messagePattern":"Trip\\.com is asking for a verification; complete it in your browser session and retry","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/trip/hotel.js","lineNumber":40,"sourceCode":"    browser: true,\n    navigateBefore: false,\n    args: [\n        { name: 'id', required: true, positional: true, help: 'Numeric Trip.com hotel id (discover via the hotels list; e.g. 715233)' },\n    ],\n    columns: [\n        'hotelId', 'name', 'enName',\n        'star', 'score', 'scoreLabel', 'reviewCount', 'ratingBreakdown',\n        'facilities', 'checkInOut',\n        'cityName', 'address', 'lat', 'lon',\n        'url',\n    ],\n    func: async (page, kwargs) => {\n        const hotelId = parseHotelId('id', kwargs.id);\n        const url = buildHotelDetailUrl(hotelId);\n        await page.goto(url);\n        const waitResult = await page.evaluate(WAIT_FOR_HOTEL_DETAIL_JS);\n        if (waitResult === 'captcha') {\n            throw new AuthRequiredError('trip.com', 'Trip.com is asking for a verification; complete it in your browser session and retry');\n        }\n        if (waitResult !== 'content') {\n            throw new CommandExecutionError(`Trip.com hotel detail page did not expose SSR hotel data (state=${String(waitResult)})`);\n        }\n        const detail = await page.evaluate(buildHotelDetailExtractJs());\n        if (!detail || typeof detail !== 'object') {\n            throw new CommandExecutionError('Trip.com hotel detail SSR extraction returned malformed data');\n        }\n        if (!detail.hotelId || !detail.name) {\n            throw new EmptyResultError('trip hotel', `No detail exposed for hotel id ${hotelId}`);\n        }\n        return [{ ...detail, url }];\n    },\n});\n","sourceCodeStart":22,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/hotel.js#L22-L55","documentation":"This AuthRequiredError is raised when WAIT_FOR_HOTEL_DETAIL_JS reports state 'captcha' after navigating to the hotel detail URL — Trip.com served a bot-verification (captcha) challenge instead of the SSR hotel content. The library refuses to bypass it and asks you to clear the challenge in a logged-in browser session and retry.","triggerScenarios":"page.goto(buildHotelDetailUrl(hotelId)) lands on a verification page: the session cookie is missing/expired, the IP is flagged, request rate is too high, or no browser fingerprint/cookies accompany the request.","commonSituations":"Headless sessions with no shared cookies, datacenter IPs flagged by Trip.com, rapid successive hotel-detail scrapes, or reusing an expired session profile.","solutions":["Open the Trip.com session in a normal browser, complete the verification, then retry the command","Reuse a persistent browser profile with valid Trip.com cookies instead of a clean headless session","Slow down request rate and add delays between hotel detail requests","Switch to a residential IP or different network if the current IP is flagged"],"exampleFix":"// before\nawait tripHotelDetail({ id: hotelId }); // fails with captcha\n// after\n// 1) clear captcha in your interactive browser session\n// 2) rerun with the same profile/cookies\nawait tripHotelDetail({ id: hotelId, profile: 'my-session' });","handlingStrategy":"retry","validationCode":"if (!process.env.TRIP_SESSION_COOKIES) {\n  console.warn('No Trip.com session cookies set — captcha risk is high');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await tripHotelDetail({ id });\n} catch (e) {\n  if (e instanceof AuthRequiredError) {\n    await promptCaptchaResolution(); // complete verification in browser\n    return await tripHotelDetail({ id }); // retry once with same session\n  }\n  throw e;\n}","preventionTips":["Use a persistent browser profile with valid Trip.com cookies","Throttle hotel-detail requests to avoid anti-bot triggers","Avoid datacenter IPs; prefer residential connections for scraping","Detect captcha states early and pause instead of hammering retries"],"tags":["captcha","auth","scraping","trip-com","anti-bot"],"backgroundTag":"captcha-challenge","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}