Show HN: Ddgr – search DuckDuckGo from your terminal
github.com
github.com
https://gitlab.com/surfraw/Surfraw
https://wiki.archlinux.org/index.php/Surfraw
https://en.wikipedia.org/wiki/Surfraw
> Surfraw (Shell Users Revolutionary Front Rage Against the Web) is a free public domain POSIX-compliant (i.e. meant for Linux, FreeBSD etc.) command-line shell program for interfacing with a number of web-based search engines.[1] It was created in July 2000 by Julian Assange[2] and is licensed in the public domain[3] and written in the Bourne shell language.
Yes, it's apparently that Julian Assange.
$ sudo apt install surfraw
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libalgorithm-c3-perl libb-hooks-endofscope-perl libcache-perl libclass-accessor-chained-perl
libclass-c3-perl libclass-c3-xs-perl libclass-data-inheritable-perl libclass-errorhandler-perl
libclass-inspector-perl libclass-singleton-perl libdata-optlist-perl libdata-page-perl
libdatetime-format-mail-perl libdatetime-format-w3cdtf-perl libdatetime-locale-perl libdatetime-perl
libdatetime-timezone-perl libdevel-caller-perl libdevel-lexalias-perl libdevel-stacktrace-perl
libeval-closure-perl libexception-class-perl libfeed-find-perl libfile-nfslock-perl
libfile-sharedir-perl libheap-perl liblwp-authen-wsse-perl libmodule-implementation-perl
libmodule-pluggable-perl libmro-compat-perl libnamespace-autoclean-perl libnamespace-clean-perl
libpackage-stash-perl libpackage-stash-xs-perl libpadwalker-perl libparams-util-perl
libparams-validate-perl libparams-validationcompiler-perl libreadonly-perl libref-util-perl
libref-util-xs-perl libspecio-perl libsub-exporter-perl libsub-identify-perl libsub-install-perl
liburi-fetch-perl liburi-template-perl libvariable-magic-perl libwww-opensearch-perl libxml-atom-perl
libxml-feed-perl libxml-libxslt-perl libxml-rss-perl libxml-xpath-perl surfraw-extra
Suggested packages:
libtest-fatal-perl screen
The following NEW packages will be installed:
libalgorithm-c3-perl libb-hooks-endofscope-perl libcache-perl libclass-accessor-chained-perl
libclass-c3-perl libclass-c3-xs-perl libclass-data-inheritable-perl libclass-errorhandler-perl
libclass-inspector-perl libclass-singleton-perl libdata-optlist-perl libdata-page-perl
libdatetime-format-mail-perl libdatetime-format-w3cdtf-perl libdatetime-locale-perl libdatetime-perl
libdatetime-timezone-perl libdevel-caller-perl libdevel-lexalias-perl libdevel-stacktrace-perl
libeval-closure-perl libexception-class-perl libfeed-find-perl libfile-nfslock-perl
libfile-sharedir-perl libheap-perl liblwp-authen-wsse-perl libmodule-implementation-perl
libmodule-pluggable-perl libmro-compat-perl libnamespace-autoclean-perl libnamespace-clean-perl
libpackage-stash-perl libpackage-stash-xs-perl libpadwalker-perl libparams-util-perl
libparams-validate-perl libparams-validationcompiler-perl libreadonly-perl libref-util-perl
libref-util-xs-perl libspecio-perl libsub-exporter-perl libsub-identify-perl libsub-install-perl
liburi-fetch-perl liburi-template-perl libvariable-magic-perl libwww-opensearch-perl libxml-atom-perl
libxml-feed-perl libxml-libxslt-perl libxml-rss-perl libxml-xpath-perl surfraw surfraw-extra
0 upgraded, 56 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,883 kB of archives.
After this operation, 29.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.Unlike the web interface, you can specify the number of search results you would like to see per page; more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability.
A big advantage of ddgr over googler is DuckDuckGo works over the Tor network.
ddgr is available in the repos of many distros as well as on PyPI.
Big up!
I'm not sure I follow. Is there an option to route this command over Tor? DuckDuckGo has a dot onion but queries on DuckDuckGo.com aren't routed over Tor.
But maybe you're referring to API access? I'm not sure if Tor users are outright blocked (and if the block is any different to other "abusive" IPs).
ddgr \!hn ddgr ddgr \!ety glaucousAs you can see, you can only have it one way (either text or GUI by default) and we kept it the default one.
But when I select something in ddgr, it says it's opened lynx but the display still just shows a list of 10 results.
If I hit q, it drops me back to ddgr, and then a quit again exits the program.
I don't want to jump to saying the issue is ddgr but was a little surprised.
It's still very useful since a lot of what I do needs images anyways, and it's IMHO silly to try to do GUI browsing in terminal, just thought I'd mention it.
Thanks for being so active in the comments!
(Trying to be extra positive since I know HN can be a little hypercritical, and the people who loved it aren't necessarily going to drop in and say so beyond an upvote :) )
1. sudo apt install lynx
2. export BROWSER=lynx
3. ddgr hello world
4. Press 1 (to open the first result in lynx)
The site is opened in lynx as expected.This gets image search results and can be embedded into other projects !
(Ex: If I type in "ip" merely return my IP, not a long list of whois DBs)
There are a number of "instant" bangs, though it's not clear if these deliver what you want: https://duckduckgo.com/bang?q=instant
You can incorporate bang int commandlinee search, though bangs ("!") generally require quoting to avoid bash / shell interpretation.
I meant more like the various cheatsheets.
(Ex: https://duckduckgo.com/?q=vim+cheat+sheet)
That query would pull up search results, but not the cheat sheet itself. Or if I do "roll 3 dice" I get unicode dice, but not the numerical sum like on the web version.
Anyways, this is really a minor gripe - this is a really cool tool and I appreciate the time you've put into it.
I can see myself using it a lot in the future! :)
ddgr ip --npddgr -n 1 --np ip
gets close
(setting -n to 0 gives a lot of results for some reason?)
Anyways, very small gripe - really like this program. Thanks for your efforts!
Thanks for the compliment! Glad to know you like it.
Update: In fact, there was an option and an extra API to fetch only the instant answer. But it seemed like a overkill because the instant answer comes along with the other results. So I removed that additional API a while back.
Coming to the question - the advantage `ddgr` provides is much more flexibility to the DDG interface or in other words, easy access to parameters you may want to tweak. For example, show only 10 results per page. Please check the program options for more.
One can argue, why not use a text browser? Yes, if scrolling around, pressing tabs to reach a link/field and pressing Enter on it to open the URL/enter text doesn't bother a user (s)he doesn't need `ddgr`.