使用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': '
    '}]

相关推荐
哪 吒2 分钟前
突破亚马逊壁垒,Web Unlocker API 助您轻松获取数据
前端·网络·python·网络安全
岸边的风4 分钟前
JavaScript篇:【前端必备】数组方法大全:从‘会写’到‘玩出花’,你掌握几个?
开发语言·前端·javascript
HoroMin18 分钟前
在Spring Boot中自定义JSON返回日期格式的指南
java·开发语言·spring boot·注解
汪洪墩24 分钟前
使用Mars3d加载热力图的时候,出现阴影碎片
开发语言·前端·javascript·vue.js·cesium
木木黄木木25 分钟前
使用Three.js创建炫酷的3D玻璃质感动态效果
开发语言·javascript·3d
代码老y29 分钟前
爬虫技术:数据挖掘的深度探索与实践应用
人工智能·爬虫·python·数据挖掘
大模型铲屎官44 分钟前
【深度学习-Day 29】PyTorch模型持久化指南:从保存到部署的第一步
人工智能·pytorch·python·深度学习·机器学习·大模型·llm
@小红花1 小时前
Python从入门到精通
开发语言·python
百锦再1 小时前
自动打电话软件设计与实现
python·django·html·api·语音·打电话
androidwork1 小时前
Kotlin实现文件上传进度监听:RequestBody封装详解
android·开发语言·kotlin