我们每天都要在网上寻找信息. 你也可以在网上找到任何信息. 因此搜索引擎也被设计成能够帮助我们从垃圾中快速筛选出有用信息的样子.
常用的搜索引擎有 Google, Bing, 和 DuckDuckGo. 不过它们都有一个共同点,那就是需要用浏览器(比如 Firefox 和 Chromium)来访问.
一般情况下这都不是什么问题; 但是如果你只有终端环境而没有 GUI 和浏览器怎么办呢, 如果你有 GUI 和浏览器但是你只想在不离开终端的情况下做一个快速搜索怎么办呢.
为此, Googler 诞生了.
注意: Googler 并不隶属于 Google .
Googler 是一个让你在命令行使用 Google (Web & News) 和 Google Site Search 的小工具,它虽然小巧但功能强大.
Googler 最初是为想在无 X 环境下使用 Google 的人所设计的. 你可以将它与像 lynx 或 links 这样的基于文本的浏览器整合,以便在命令行直接打开搜索结果. 但是现在它已经发展成为一个非常方便,非常灵活的工具了. 其功能也有了大大的扩展.
Googler 需要 Python 3.3 以上版本支持. 且仅支持每个次要版本的最新补丁版本.
Googler 现在已经支持大多数发行版本来通过包管理器安装,下面以几个常见的发行版本为例:
# Debian / Ubuntu
$ apt-get install googler
# Fedora
$ dnf install googler
# macOS
$ brew install googler
如果你使用的发行版本不支持通过包管理器安装,还有一个更简单的方法, Googler 只是一个独立的脚本, 你只需要下载这个文件就行了.
$ sudo curl -o /usr/local/bin/googler https://raw.githubusercontent.com/jarun/googler/v3.8/googler && sudo chmod +x /usr/local/bin/googler
$ sudo googler -u
Googler 会显示出搜索结果的标题,URL 以及摘要,你可以直接从终端调用浏览器访问这些搜索结果. 搜索结果以页的形式组织,你可以上下进行翻页. 同时你还可以在同一个 Googler 实例上进行连续的搜索.
你可以指定搜索结果的数量, 限制搜索 bt duration 等等, 而且搜索结果非常清爽,没有那些广告和流氓网址. Shell 补全功能使得你无需记忆任何参数.
usage: googler [-h] [-s N] [-n N] [-N] [-c TLD] [-l LANG] [-x] [-C]
[--colors COLORS] [-j] [-t dN] [-w SITE] [--unfilter]
[-p PROXY] [--noua] [--notweak] [--json] [--url-handler UTIL]
[--show-browser-logs] [--np] [-u] [--include-git] [-v] [-d]
[KEYWORD [KEYWORD ...]]
Google from the command-line.
positional arguments:
KEYWORD search keywords
optional arguments:
-h, --help show this help message and exit
-s N, --start N start at the Nth result
-n N, --count N show N results (default 10)
-N, --news show results from news section
-c TLD, --tld TLD country-specific search with top-level domain .TLD,
e.g., 'in' for India
-l LANG, --lang LANG display in language LANG
-x, --exact disable automatic spelling correction
-C, --nocolor disable color output
--colors COLORS set output colors (see man page for details)
-j, --first, --lucky open the first result in web browser and exit
-t dN, --time dN time limit search [h5 (5 hrs), d5 (5 days), w5 (5
weeks), m5 (5 months), y5 (5 years)]
-w SITE, --site SITE search a site using Google
--unfilter do not omit similar results
-p PROXY, --proxy PROXY
tunnel traffic through an HTTP proxy; PROXY is of the
form [http://][user:password@]proxyhost[:port]
--noua disable user agent
--notweak disable TCP optimizations and forced TLS 1.2
--json output in JSON format; implies --noprompt
--url-handler UTIL custom script or cli utility to open results
--show-browser-logs do not suppress browser output (stdout and stderr)
--np, --noprompt search and exit, do not prompt
-u, --upgrade perform in-place self-upgrade
--include-git when used with --upgrade, get latest git master
-v, --version show program's version number and exit
-d, --debug enable debugging
omniprompt keys:
n, p fetch the next or previous set of search results
index open the result corresponding to index in browser
f jump to the first page
o [index|range|a ...] open space-separated result indices, numeric ranges
(sitelinks unsupported in ranges), or all, in browser
open the current search in browser, if no arguments
O [index|range|a ...] like key 'o', but try to open in a GUI browser
g keywords new Google search for 'keywords' with original options
should be used to search omniprompt keys and indices
c index copy url to clipboard
u toggle url expansion
q, ^D, double Enter exit googler
? show omniprompt help
* other inputs issue a new search with original options
让我们看一些实际的例子.
查看更多搜索结果
$ googler hello world
$ googler -n 15 -s 3 -t m14 -w imdb.com jungle book
$ googler -N gadgets
$ googler -h
或者
$ man googler
1. 与文本浏览器实现整合
Googler 天然与文本浏览器相适应,只需要设置一下 BROWSER 环境变量即可. 像这样:
$ export BROWSER=w3m
若只是临时设置,可以这样:
$ BROWSER=w3m googler query
2. 终端阅读模式或者说阅读者视图
Googler 可以很方便的与其他工具整合, 给你提供一个无干扰的阅读环境. 详细信息可参见: http://t.cn/ECy4lB1 .
3. 配色
Googler 允许你通过一个 6 位字符的字符串来自定义配色方案, 其格式与 BSD LSCOLORS 一致.
4. 其它一些特性
Googler 的受众范围有限,但如果你更喜欢终端,它是一个不错的好工具. 虽然用的不多,但是我很喜欢 Googler,我会一直留着它. 想了解更多关于 Googler 的信息, 请访问它的官方页面:https://github.com/jarun/googler
来源:GitHub 原文:http://t.cn/ECycY9H 题图:来自谷歌图片搜索 版权:本文版权归原作者所有