{"record":{"id":"837d1e1e64b2bdf5","repo":"NanmiCoder/MediaCrawler","slug":"300011","errorCode":"300011","errorMessage":"XHS account security restriction, code: {self.SECURITY_LIMIT_CODE}","messagePattern":"XHS account security restriction, code: (.+?)","errorType":"exception","errorClass":"PlatformAccessError","httpStatus":null,"severity":"critical","filePath":"media_platform/xhs/client.py","lineNumber":182,"sourceCode":"            raise Exception(msg)\n\n        response_data: Optional[Dict] = None\n        try:\n            candidate_data = response.json()\n            if isinstance(candidate_data, dict):\n                response_data = candidate_data\n        except (TypeError, ValueError):\n            pass\n\n        response_code = (\n            str(response_data.get(\"code\"))\n            if response_data is not None and response_data.get(\"code\") is not None\n            else \"\"\n        )\n        if response_code == str(self.IP_ERROR_CODE):\n            raise IPBlockError(self.IP_ERROR_STR)\n        if response_code == str(self.SECURITY_LIMIT_CODE):\n            raise PlatformAccessError(\n                f\"XHS account security restriction, code: {self.SECURITY_LIMIT_CODE}\"\n            )\n\n        if return_response:\n            return response.text\n        data: Dict = response_data if response_data is not None else response.json()\n        if data[\"success\"]:\n            return data.get(\"data\", data.get(\"success\", {}))\n        # IP_ERROR_CODE / SECURITY_LIMIT_CODE are already handled above, before return_response.\n        elif data[\"code\"] in (self.NOTE_NOT_FOUND_CODE, self.NOTE_ABNORMAL_CODE):\n            raise NoteNotFoundError(f\"Note not found or abnormal, code: {data['code']}\")\n        else:\n            err_msg = data.get(\"msg\", None) or f\"{response.text}\"\n            raise DataFetchError(err_msg)\n\n    @staticmethod\n    def _build_query_string(params: Dict) -> str:\n        \"\"\"Build URL query string with encoding matching browser behavior (commas not encoded)\"\"\"","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/xhs/client.py#L164-L200","documentation":"PlatformAccessError raised by XiaoHongShuClient.request when the response JSON carries code 300011 (SECURITY_LIMIT_CODE). This means the logged-in xhs account itself is under a security restriction (frequently the account is prompted to verify identity on next login), independent of IP. The message includes the code so operators can distinguish account-level from IP-level blocks.","triggerScenarios":"Signed xhs API calls with a cookie whose account triggered risk control: too many requests per account, automation detected, or the account was reported/locked. Every API call returns code 300011 until the account is unlocked.","commonSituations":"Reusing one cookie for very long or aggressive crawls; account flagged after logging in from unusual locations (proxy IPs); sharing the crawler cookie across multiple machines.","solutions":["Log into xiaohongshu in a browser with that account, complete any security verification prompted, then export a fresh cookie.","Switch to a different (warmed) account cookie if the current one stays restricted.","Reduce per-account request volume and rate; consider rotating multiple accounts.","Catch PlatformAccessError, inspect the code in the message, and stop crawling with that cookie to avoid escalating the restriction."],"exampleFix":"// before\nres = await xhs_client.request(\"GET\", uri, params=params)\n// after\nfrom media_platform.xhs.exception import PlatformAccessError\ntry:\n    res = await xhs_client.request(\"GET\", uri, params=params)\nexcept PlatformAccessError as e:\n    if \"300011\" in str(e):\n        raise RuntimeError(\"xhs account restricted: complete verification in browser and refresh cookie\")\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from media_platform.xhs.exception import PlatformAccessError\ntry:\n    res = await xhs_client.request(method, uri, **kwargs)\nexcept PlatformAccessError as e:\n    if \"300011\" in str(e):\n        utils.logger.error(\"xhs account restricted - stop crawl, verify account in browser\")\n        raise SystemExit(2)\n    raise","preventionTips":["Do not run one account cookie 24/7 - rotate accounts and cap per-account volume.","Complete any pending identity verification in a browser before exporting cookies.","Distinguish account restriction (300011) from IP block (300012) before choosing a fix."],"tags":["xhs","account-restriction","anti-bot","cookies"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}