当前位置: 首页 > news >正文

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

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

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

重要参数

官网参数

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 代码

from duckduckgo_search import DDGS
from pprint import pprintwith 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.c*******v732WBOg','description': '🎉欢迎************************..','duration': '0:19','embed_html': '<iframe width="1280" height="720" ''src="https://ww******732WBOg?autoplay=1" ''frameborder="0" allowfullscreen></iframe>','embed_url': 'https://ww**732WBOg?autoplay=1','image_token': 'ba7b4b8ce1c8**8bca1351c81bcc6b4a25e65de2a','images': {'large': 'https://tse2.mm.bin**hOsA1potKn9%2foWFw&pid=Api','medium': 'https://tse2.m**qQhOsA1potKn9%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': '75166****156367.mp4','uploader': '****'}]
http://www.xdnf.cn/news/1059391.html

相关文章:

  • 设计模式精讲 Day 6:适配器模式(Adapter Pattern)
  • 设计模式之责任链模式
  • 《仿盒马》app开发技术分享--未完成订单列表展示逻辑优化(61)
  • SKUA-GOCAD入门教程-第八节 线的创建与编辑5
  • C/Fortran多核并行计算
  • wireshark过滤器的使用
  • tomcat 配置规范
  • stack 和 queue练习
  • 【面试题001】生产环境中如何排查MySQL CPU占用率高达100%?
  • linux kernel优化之rootfs
  • CANFD加速是什么?和CANFD有什么区别?
  • linux 下 jenkins 构建 uniapp node-sass 报错
  • 使用@SpringJUnitConfig注解开发遇到的空指针问题
  • spring-webmvc @InitBinder 典型用法
  • 《挑战你的控制力!开源项目小游戏学习“保持平衡”开发解析:用HTML+JS+CSS实现物理平衡挑战》​
  • 【51单片机】8. 矩阵LED显示自定义图案、动画
  • 用idea操作git缓存区回退、本地库回退、远程库回退
  • singlefligt使用方法和源码解读
  • 无需公网IP:Termux+手机+内网穿透实现Minecraft远程多人联机
  • Uniapp 中根据不同离开页面方式处理 `onHide` 的方法
  • python3:线程管理进程
  • 前端打断点
  • python校园服务交流系统
  • 第十八天:初级数据库学习笔记2
  • easyexcel基于模板生成报表
  • RabbitMQ七种工作模式
  • 21.加密系统函数
  • macOS版的节点小宝上架苹果APP Store了
  • git的使用——初步认识git和基础操作
  • DeepForest开源程序是用于 Airborne RGB 机器学习的 Python 软件包