duckduckgo命令行的零点击api
ddg的Python项目详细描述
Duck Duck Go命令行的零点击api
安装
$ pip install ddg
或者来源:
$ python setup.py install
用法
ddg [-h] [-b] [-d] [-j] [-l] [-s] [-u] [query [query ...]]
www.duckduckgo.com命令行的零点击api
- 位置参数:
- 查询搜索查询
- 可选参数:
-h, --help show this help message and exit -b, --bang open the !bang redirect url in a new browser tab -d, --define return the definition result -j, --json return the zero-click info api json response -l, --lucky open the result url in a new browser tab -s, --search launch a DuckDuckGo search in a new browser tab -u, --url return the result url
示例
从命令行调用ddg访问Duck Duck Go Zero-Click Info API
$ddg red-black tree A red–black tree is a type of self-balancing binary search tree, a data structure used in computer science, typically used to implement associative arrays.
获取答案源的url
$ ddg red-black tree -u https://en.wikipedia.org/wiki/Red-black_tree
组合标志的行为与预期一致
$ ddg schnauzer -d -u http://www.merriam-webster.com/dictionary/schnauzer
使用-b标志在Web浏览器中启动!Bang redirect
在Wolfram Alpha上启动查询
$ ddg wa integral of sin x / x from negative inf to inf -b
在Stack Overflow上启动搜索
$ ddg so [c++11] lambda return values -b
使用-s
启动search on Duck Duck Go$ ddg Lord of the Rings -s
使用-l
直接启动result url$ ddg python webbrowser -l
ddg与shell中的其他实用程序配合得很好
$ echo "shark" | ddg -dl
$ ddg welsh corgi -u | pbcopy
$ ls | ddg -du
使用-j从api输出json response
$ ddg simpsons characters -j >> file.txt
谢谢
duckduckgo模块是对http://github.com/crazedpsyc/python-duckduckgo的修改。
来自http://github.com/mikejs/python-duckduckgo的原始duckduckgo模块源(过时)
发布历史
0.2.2(2012年12月20日)
- 修复了用特殊字符打印结果时的错误处理
0.2.1(2012-12-18)
- 在duckduckgo模块中引发异常时,报告错误 然后不返回。这允许ddg.py继续下一个查询 而不是执行sys退出(1)。
- 更新了自述文件
- 已修复许可证文件中的格式设置
- 更改了对rst文件的更改
- 更新了setup.py文件
- 更新了所有输入参数的帮助
0.2.0(2012-12-17)
- 更改了-d标志的行为。而不是预先查询 define,现在只需在搜索 回答问题。
- 用更多示例更新了自述文件。
0.1.7(2012-12-16)
- 添加了新的trove分类器,使代码更符合pep8
0.1.6(2012-12-16)
- 修复了-b前缀的问题,请升级到最新版本 使用pip安装–升级ddg
0.1.5(2012-12-15)
- 更新了麻省理工学院的许可证
0.1.4(2012-12-15)
- 使用webbrowser而不是依赖于操作系统的popen命令
0.1.1(2012-12-15)
- 第一个工作版本,初始版本