stackoverflow上的搜索答案
askstack的Python项目详细描述
阿斯克斯塔克
堆栈溢出时搜索答案。可以使用google、bing或duckduckgo搜索 引擎。
只需向脚本传递一些关键字,脚本就会使用搜索引擎查找 堆栈上最相关的页溢出。
然后,它将从问题页或完整的 回答文本。
简单示例:
$ askstack python delete dict key --------------------------------------------------------------------------- Question: How to remove a key from a python dictionary? my_dict.pop('key', None) Answer from: https://stackoverflow.com/questions/11277432 --------------------------------------------------------------------------- Question: Delete an item from a dictionary del d[key] Answer from: https://stackoverflow.com/questions/5844672 ---------------------------------------------------------------------------
注释
- 适用于Python2.7和Python3.4+
安装
使用pip安装:
pip install askstack
用法
Usage: askstack keywords... [options] search answers on stackoverflow Options: --version show program's version number and exit -h, --help show this help message and exit -a ANSWERS number of answers to retrieve (default: 2) -e ENGINE search engine to use: 'google', 'bing', 'duckduckgo' or 'fallback' - fallback will try google and fallback to bing and duckduckgo if a search fails (default: fallback) -f, --fulltext get the full answer text (default: disabled) -s SLEEP sleep time between requests (default: 0.5) -t TIMEOUT timeout in seconds to wait for reply (default: 5)
示例
如果您感到幸运,请只获取第一个代码片段:
$ askstack linux gzip directory -a 1
获得完整的第一个答案:
$ askstack linux gzip directory -a 1 -f
只使用duckduckgo作为搜索引擎,尝试获得三个答案:
$ askstack linux gzip directory -a 3 -e duckduckgo