You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

DuckDuckGoSearch限流报错求助:是否有官方API可用?

DuckDuckGoSearch限流错误解决及API说明

一、限流错误(Ratelimit)解决方法

  • 增加请求间隔:调用搜索接口后添加1-2秒延迟,避免短时间高频请求触发限流机制。
  • 更换请求IP:使用代理IP分散请求来源,绕过单IP的频次限制。
  • 降低请求频率:合并重复或批量搜索需求,减少单位时间内的请求次数。
  • 调整工具配置:检查ddg-search工具的内置参数,部分框架支持设置请求间隔、重试次数等,优化后可降低限流概率。

二、DuckDuckGoSearch的API情况

DuckDuckGo有官方免费API,无需密钥即可使用,相比网页抓取方式更稳定,不易触发限流:

  • 基础搜索接口支持JSON格式返回,示例代码:
    import requests
    
    def ddg_search(query):
        api_url = f"https://api.duckduckgo.com/?q={query}&format=json&no_html=1&no_redirect=1"
        resp = requests.get(api_url)
        return resp.json()
    
    # 使用示例
    search_result = ddg_search("machine learning basics")
    print(search_result["AbstractText"])
    
  • API返回包含摘要、相关链接、即时答案等结构化数据,便于直接解析使用。

原始代码

from agent import load_agent
import streamlit as st

strategy = st.radio(
    "Reasoning strategy",
    ("plan-and-solve", "zero-shot-react", ))

tool_names = st.multiselect(
    'Which tools do you want to use?',
    [
        "google-search", "ddg-search", "wolfram-alpha", "arxiv",
        "wikipedia", "python_repl", "pal-math",
        "llm-math"
    ],
    ["ddg-search", "wolfram-alpha", "wikipedia","google-search"])

agent_chain = load_agent(tool_names=tool_names, strategy=strategy)

错误信息:DuckDuckGoSearchException: _aget_url() https://links.duckduckgo.com/d.js DuckDuckGoSearchException: Ratelimit

内容的提问来源于stack exchange,提问作者roudan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 22:52:33