使用duckduckgo_search python api 进行免费且不限次数的搜索

使用duckduckgo_search python api 进行免费且不限次数的搜索

  • 搜索内容
  • 搜索新闻
  • 搜索图片
  • 搜索视频

重要参数

官网参数

python 复制代码
region='wt-wt',  # wt-wt、us-en、uk-en、ru-ru 等。默认为"wt-wt"
safesearch='off',  # on, moderate, off. Defaults to "moderate"
timelimit='y',     #  d, w, m, y. Defaults to None
max_results=10  # 最大结果数量

python 代码

python 复制代码
from duckduckgo_search import DDGS
from pprint import pprint

with DDGS(
    timeout=20,
    proxies="http://localhost:7890"  # VPN代理
) as ddgs:
    pprint([r for r in ddgs.text("大模型", region='cn-zh', max_results=10)])  # 搜索内容
    # pprint([r for r in ddgs.news("CHATGPT", region='cn-zh', max_results=10)])  # 搜索新闻
    # pprint([r for r in ddgs.images("刘亦菲", region='cn-zh', max_results=10)])  # 搜索图片
    # pprint([r for r in ddgs.videos("搞笑视频", region='cn-zh', max_results=10)])  # 搜索图片

返回体

  • 搜索内容

    {
    'body': ...,
    'href': ...,
    'title': ....
    }

  • 搜索新闻

    {
    'body': '',
    'date': '2025-06-18T09:02:00+00:00',
    'image': '',
    'source': '',
    'title': '',
    'url': 'https://www***************25/0618/26913.html'
    }

  • 搜索图片

    {
    'height': 1928,
    'width': 1296,
    'image': 'https://n.sinaimg.cn/sinakd201********8832682.jpg',
    'source': 'Bing',
    'thumbnail': 'https://tse1.mm.bing.net/th?id=OIP.8T****gHaLB&pid=Api',
    'title': '全球首映。',
    'url': 'https://k.sin
    z.html?from=ent&subch=oent',
    }

  • 搜索视频

    {
    'content': 'https://www.youtube.cv732WBOg',
    'description': '🎉欢迎
    *****************..',
    'duration': '0:19',
    'embed_html': '<iframe width="1280" height="720" '
    'src="https://ww732WBOg?autoplay=1" '
    'frameborder="0" allowfullscreen>',
    'embed_url': 'https://ww
    732WBOg?autoplay=1',
    'image_token': 'ba7b4b8ce1c8
    8bca1351c81bcc6b4a25e65de2a',
    'images': {'large': 'https://tse2.mm.bin
    hOsA1potKn9%2foWFw&pid=Api',
    'medium': 'https://tse2.mqQhOsA1potKn9%2foWFw&pid=Api',
    'motion': '',
    'small': 'https://tse2
    bqQhOsA1potKn9%2foWFw&pid=Api'},
    'provider': 'Bing',
    'published': '2025-06-17**:52.0000000',
    'publisher': 'You**be',
    'statistics': {'viewCount': None},
    'title': '75166156367.mp4',
    'uploader': '
    '}]

相关推荐
冷凝雨9 小时前
复数乘法(C & Simulink)
c语言·开发语言·信号处理·simulink·dsp
CoderCodingNo9 小时前
【GESP】C++五级真题(贪心思想考点) luogu-B4071 [GESP202412 五级] 武器强化
开发语言·c++·算法
0和1的舞者9 小时前
Spring AOP详解(一)
java·开发语言·前端·spring·aop·面向切面
MoonBit月兔9 小时前
年终 Meetup:走进腾讯|AI 原生编程与 Code Agent 实战交流会
大数据·开发语言·人工智能·腾讯云·moonbit
智航GIS9 小时前
8.2 面向对象
开发语言·python
小小星球之旅9 小时前
CompletableFuture学习
java·开发语言·学习
蹦蹦跳跳真可爱58910 小时前
Python----大模型(GPT-2模型训练加速,训练策略)
人工智能·pytorch·python·gpt·embedding
xwill*10 小时前
π∗0.6: a VLA That Learns From Experience
人工智能·pytorch·python
kylezhao201910 小时前
C# 语言基础(变量、数据类型、流程控制、面向对象编程)
开发语言·计算机视觉·c#·visionpro
还不秃顶的计科生10 小时前
LeetCode 热题 100第二题:字母易位词分组python版本
linux·python·leetcode