{"record":{"id":"45f7fb3dc6eb9928","repo":"searxng/searxng","slug":"data-message-forbid-spider-access","errorCode":null,"errorMessage":"{data[message] | Forbid spider access}","messagePattern":"\\{data\\[message\\] \\| Forbid spider access\\}","errorType":"exception","errorClass":"SearxEngineAccessDeniedException","httpStatus":null,"severity":"warning","filePath":"searx/engines/baidu.py","lineNumber":139,"sourceCode":"        params[\"cookies\"] = get_image_cookies(params[\"headers\"])\n\n    params[\"url\"] = f\"{query_url}?{urlencode(query_params)}\"\n    params[\"allow_redirects\"] = False\n    return params\n\n\ndef response(resp):\n    # Detect Baidu Captcha, it will redirect to wappass.baidu.com\n    if 'wappass.baidu.com/static/captcha' in resp.headers.get('Location', ''):\n        raise SearxEngineCaptchaException()\n\n    text = resp.text\n    if baidu_category == 'images':\n        # baidu's JSON encoder wrongly quotes / and ' characters by \\\\ and \\'\n        text = text.replace(r\"\\/\", \"/\").replace(r\"\\'\", \"'\")\n    data = json.loads(text, strict=False)\n    if data.get(\"antiFlag\") == 1:\n        raise SearxEngineAccessDeniedException(data.get(\"message\", \"Forbid spider access\"))\n    parsers = {'general': parse_general, 'images': parse_images, 'it': parse_it}\n\n    return parsers[baidu_category](data)\n\n\ndef parse_general(data):\n    results = []\n    if not data.get(\"feed\", {}).get(\"entry\"):\n        raise SearxEngineAPIException(\"Invalid response\")\n\n    for entry in data[\"feed\"][\"entry\"]:\n        if not entry.get(\"title\") or not entry.get(\"url\"):\n            continue\n\n        published_date = None\n        if entry.get(\"time\"):\n            try:\n                published_date = datetime.fromtimestamp(entry[\"time\"])","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/searxng/searxng/blob/9fea41204fdfa7a5cfa15b0ebd12904c520478ce/searx/engines/baidu.py#L121-L157","documentation":"Raised in baidu's response() when the parsed JSON contains antiFlag == 1: Baidu's anti-spider system flagged the request. The message defaults to 'Forbid spider access' unless the API supplies one. It maps to SearxEngineAccessDeniedException, marking the engine access-denied (temporarily banned).","triggerScenarios":"A search request (often the images category JSON API) returns JSON with \"antiFlag\":1 — Baidu's server-side bot detection rejected the query from this IP/cookie session.","commonSituations":"Heavy automated querying from a datacenter IP, stale or burned cookies from the engine's cookie cache, or querying in bursts that resemble scraping.","solutions":["Wait out the access-denied period (SearXNG auto-suspends then retries the engine)","Clear the cached Baidu cookies (the engine caches cookies with expiry) so fresh ones are fetched","Move the instance behind a different egress IP / proxy","Lower request frequency to Baidu"],"exampleFix":"null","handlingStrategy":"fallback","validationCode":"null","typeGuard":null,"tryCatchPattern":"try:\n    results = search(query)\nexcept SearxEngineAccessDeniedException:\n    results = []  # engine auto-banned for a period; fall back to other engines","preventionTips":["Reduce Baidu query concurrency and rate","Periodically flush cached cookies so fresh ones are fetched","Distribute searches across multiple engines/egress IPs"],"tags":["searxng","baidu","anti-bot","access-denied","rate-limit"],"backgroundTag":"upstream-access-denied-anti-bot","analyzedSha":"9fea41204fdfa7a5cfa15b0ebd12904c520478ce","analyzedAt":"2026-08-27T06:40:00.395Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}