{"record":{"id":"e6759036b0e9b43d","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"duckduckgo-search-failed-str-e","errorCode":null,"errorMessage":"DuckDuckGo search failed: {str(e)}","messagePattern":"DuckDuckGo search failed: (.+?)","errorType":"exception","errorClass":"SearchRequestError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/utils/research_web.py","lineNumber":282,"sourceCode":"    \"\"\"\n    try:\n        from ddgs import DDGS\n    except ImportError as e:\n        raise ImportError(\n            \"Could not import the 'ddgs' package required for DuckDuckGo \"\n            \"search. Please install it with `pip install -U ddgs`.\"\n        ) from e\n\n    try:\n        with DDGS(proxy=proxy) as ddgs:\n            results = [\n                result[\"href\"]\n                for result in ddgs.text(query, max_results=max_results)\n                if result.get(\"href\")\n            ]\n        return results\n    except Exception as e:\n        raise SearchRequestError(f\"DuckDuckGo search failed: {str(e)}\")\n\n\ndef _search_bing(\n    query: str, max_results: int, timeout: int, proxy: Optional[str] = None\n) -> List[str]:\n    \"\"\"\n    Helper function for Bing search with improved error handling.\n\n    Args:\n        query (str): Search query\n        max_results (int): Maximum number of results to return\n        timeout (int): Request timeout in seconds\n        proxy (str, optional): Proxy configuration\n\n    Returns:\n        List[str]: List of URLs from search results\n    \"\"\"\n    headers = {\"User-Agent\": get_random_user_agent()}","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/utils/research_web.py#L264-L300","documentation":"Raised by _search_duckduckgo when the ddgs text search raises any exception (rate limit, network failure, empty/malformed response). It is wrapped into SearchRequestError with the original message preserved.","triggerScenarios":"Calling search_on_web with engine='duckduckgo' when DuckDuckGo rate-limits the client, the proxy blocks duckduckgo.com, or ddgs returns an unexpected response shape.","commonSituations":"Running many search queries from one IP triggering DuckDuckGo rate limits; datacenter IPs being blocked; ddgs package version changes altering result keys.","solutions":["Slow down / add delays between DuckDuckGo searches","Configure a proxy in the SearchConfig","Update the ddgs package to the latest version","Fall back to another engine (serper, searxng) when this error occurs"],"exampleFix":"// before\nresults = search_on_web(config)  # engine='duckduckgo', rate-limited\n// after\ntry:\n    results = search_on_web(config)\nexcept SearchRequestError:\n    config.search_engine = \"serper\"\n    results = search_on_web(config)","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    results = search_on_web(config)\nexcept SearchRequestError:\n    config.search_engine = \"google\"\n    results = search_on_web(config)","preventionTips":["Add delays between DuckDuckGo queries to avoid rate limits","Use a proxy for datacenter IPs","Keep a fallback engine configured"],"tags":["network","rate-limit","duckduckgo"],"backgroundTag":"web-search-failed","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}