{"record":{"id":"48dd52fad5d00c2e","repo":"NanmiCoder/MediaCrawler","slug":"unable-to-parse-creator-info-from-url-url","errorCode":null,"errorMessage":"Unable to parse creator info from URL: {url}","messagePattern":"Unable to parse creator info from URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"media_platform/xhs/help.py","lineNumber":347,"sourceCode":"        CreatorUrlInfo: Object containing user_id, xsec_token, xsec_source\n    \"\"\"\n    # If it's a pure ID format (24 hexadecimal characters), return directly\n    if len(url) == 24 and all(c in \"0123456789abcdef\" for c in url):\n        return CreatorUrlInfo(user_id=url, xsec_token=\"\", xsec_source=\"\")\n\n    # Extract user_id from URL: /user/profile/xxx\n    import re\n    user_pattern = r'/user/profile/([^/?]+)'\n    match = re.search(user_pattern, url)\n    if match:\n        user_id = match.group(1)\n        # Extract xsec_token and xsec_source parameters\n        params = extract_url_params_to_dict(url)\n        xsec_token = params.get(\"xsec_token\", \"\")\n        xsec_source = params.get(\"xsec_source\", \"\")\n        return CreatorUrlInfo(user_id=user_id, xsec_token=xsec_token, xsec_source=xsec_source)\n\n    raise ValueError(f\"Unable to parse creator info from URL: {url}\")\n\n\nif __name__ == '__main__':\n    _img_url = \"https://sns-img-bd.xhscdn.com/7a3abfaf-90c1-a828-5de7-022c80b92aa3\"\n    # Get image URL addresses under multiple CDNs for a single image\n    # final_img_urls = get_img_urls_by_trace_id(get_trace_id(_img_url))\n    final_img_url = get_img_url_by_trace_id(get_trace_id(_img_url))\n    print(final_img_url)\n\n    # Test creator URL parsing\n    print(\"\\n=== Creator URL Parsing Test ===\")\n    test_creator_urls = [\n        \"https://www.xiaohongshu.com/user/profile/5eb8e1d400000000010075ae?xsec_token=AB1nWBKCo1vE2HEkfoJUOi5B6BE5n7wVrbdpHoWIj5xHw=&xsec_source=pc_feed\",\n        \"5eb8e1d400000000010075ae\",\n    ]\n    for url in test_creator_urls:\n        try:\n            result = parse_creator_info_from_url(url)","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/xhs/help.py#L329-L365","documentation":"ValueError raised by parse_creator_url_from... in xhs/help.py when a URL does not match the /user/profile/{user_id} pattern. The parser only accepts creator profile URLs of that exact shape, extracting user_id plus optional xsec_token/xsec_source query params.","triggerScenarios":"Feeding an xhs note URL ( /explore/... or /discovery/item/...), a bare user ID instead of a URL, a domain-less path, or a profile URL with an unexpected path structure into the creator-URL parser.","commonSituations":"User pastes a note link into XHS_CREATOR_ID_LIST configured for URLs; config mixes numeric IDs and URLs; URL copied from the mobile share sheet with a different host/path format.","solutions":["Use a full creator profile URL like https://www.xiaohongshu.com/user/profile/5ff0e6410000000001008400?xsec_token=...&xsec_source=pc_search.","If you only have the numeric ID, pass the ID directly (the config accepts IDs) instead of fabricating a URL of the wrong shape.","Validate/normalize URLs in config before the crawl starts."],"exampleFix":"# before\nurl = \"https://www.xiaohongshu.com/explore/65c1e9b3000000000c03a0e1\"\ninfo = parse_creator_url(url)  # ValueError\n# after\nurl = \"https://www.xiaohongshu.com/user/profile/65c1e9b3000000000c03a0e1\"\ninfo = parse_creator_url(url)","handlingStrategy":"validation","validationCode":"import re\ndef is_creator_profile_url(url: str) -> bool:\n    return bool(re.search(r'/user/profile/([^/?]+)', url))","typeGuard":"import re\ndef is_creator_url(url: str) -> bool:\n    return isinstance(url, str) and bool(re.search(r'xiaohongshu\\.com/user/profile/[^/?]+', url))","tryCatchPattern":"try:\n    info = parse_creator_url(url)\nexcept ValueError:\n    raise ValueError(f\"expected xiaohongshu.com/user/profile/<id> URL, got: {url!r}\") from None","preventionTips":["Copy creator URLs straight from the browser address bar on the profile page.","Normalize all config entries to full https URLs before the crawl.","Accept bare numeric IDs through a separate config path instead of faking URLs."],"tags":["xhs","url-parsing","config","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}