7 ms·
Show HN: Ddgr – search DuckDuckGo from your terminal
- apjana 8y agoddgr is a cmdline utility to search DuckDuckGo from the terminal. While googler is extremely popular among cmdline users, in many forums the need of a similar utility for privacy-aware DuckDuckGo came up. DuckDuckGo Bangs are super-cool too! So here's ddgr for you! 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.
- MisterOctober 8y agoJust installed it; love it. Will save me time by avoiding the need to switch from terminal to browser to use ddg [and sidesteps the less-than-optimal UI of Lynx, which I still use pretty frequently but dislike for search]. Big up!
- apjana 8y agoThank you for the compliment!
- dontbenebby 8y ago>A big advantage of ddgr over googler is DuckDuckGo works over the Tor network. 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.
- apjana 8y agoNo, it doesn't mean by default routing over Tor. There's an option to specify proxy which you can use to route your ddgr searches using the Tor network. However, Google blocks that.
- cyphar 8y agoGoogle doesn't /block/ Tor, they just make life difficult for users by giving endless captcha depending on what exit node you have (similar to what Cloudflare did until quite recently). 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).
- apjana 8y agoPlease try it out with googler.
- I_complete_me 8y agoGreat. Well done on this. I now have a new favourite dictionary on my zsh CLI thus: alias -g define='BROWSER=w3m ddgr \!wordnik ' Thank you!
- apjana 8y agoThanks for sharing this.
- vaer-k 8y agoCan you search by any duration, like googler can, or does duckduckgo prevent you from implementing that? That's my biggest complaint about ddg: can't even search by past year
- msla 8y agoReminds me of surfraw: https://gitlab.com/surfraw/Surfraw https://gitlab.com/surfraw/Surfraw https://wiki.archlinux.org/index.php/Surfraw https://wiki.archlinux.org/index.php/Surfraw https://en.wikipedia.org/wiki/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.
- apjana 8y agoThe number of dependencies is very high. From Ubuntu 18.04: $ 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.
- darkpuma 8y agoIs there a way to search for images or videos, e.g. &iax=images&ia=images ? I looked through the documentation and don't seem to see any.
- faissaloo 8y agoI find the interface really clunky to use because I need to press enter after every command.
- smhenderson 8y agoI can't tell if you're being sarcastic or not; doesn't that describe just about everything you do interactively on a command line?
- faissaloo 8y agoYes but the difference is most other programs that employ this interface are programs I would probably spend alot more time using.
- moonrobin 8y agoI think the primary advantages of something like this is more so that it enables you to use it with terminal tools, and from/in other programs (e.g. calling it from vim). There's also the benefit of increased productivity if you want to stay in terminal. It wasn't designed to to be more ergonomic than the browser based one.
- apjana 8y agoYou are right on spot! Couldn't have explained better myself.
- jaequery 8y agoWhat’s so good about DDG? I’ve used it a few times but i still don’t get the appeal to it
- cyphar 8y agoThe no tracking policy, and the large amount of built-in features (such as bang-searches). They also don't make life hard for Tor users with endless captcha (there's even an onion service for DDG).
- jaequery 8y agonot sure if that still appeals to me.
- dontbenebby 8y agoIMHO the bang commands alone make it really useful https://duckduckgo.com/bang?q= https://duckduckgo.com/bang?q=
- theophrastus 8y agoAre the bang searches supposed to always open a gui browser? Because they seem that way. Search Hacker News for "ddgr" and it opens up (in my case) a tab on firefox: ddgr \!hn ddgr
- apjana 8y agoThere's no such hard-coding. For me it opens in w3m. Probably you have BROWSER defined to a GUI browser.
- TheGrassyKnoll 8y agoWith bangs, I'm getting a new tab in Firefox as well.
- apjana 8y agoWhat's the output of `echo $BROWSER`?
- theophrastus 8y agoIn my case BROWSER isn't set. And yet ddgr still found my firefox in another workspace and opened a tab on it. I was just wondering if there's a means to force a terminal/text output from something akin to: ddgr \!ety glaucous
- apjana 8y agoThis is inherited from Python's webbrowser module. It would find a GUI browser by default. Please set `BROWSER` to your preferred text-based browser. To force use the GUI browser, use the prompt key `O` or the progrma option `--gb`. As you can see, you can only have it one way (either text or GUI by default) and we kept it the default one.
- dontbenebby 8y agoI haven't messed with text based browsers for a while - do you have a favorite?
- bootcat 8y agoSomething related, I made a DuckDuckGo Images API here - https://github.com/deepanprabhu/duckduckgo-images-api https://github.com/deepanprabhu/duckduckgo-images-api. This gets image search results and can be embedded into other projects !
- dontbenebby 8y agoIs there a way to supress the search results if I only want an instant answer? (Ex: If I type in "ip" merely return my IP, not a long list of whois DBs)
- apjana 8y agoTry ddgr ip --np
- dontbenebby 8y agoThanks! Looks like ddgr -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!
- apjana 8y agon=0 is the default and results in the default behavior - sow all fetched results in the same page. 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.
- dredmorbius 8y agoInstant results are supported: https://github.com/jarun/ddgr https://github.com/jarun/ddgr There are a number of "instant" bangs, though it's not clear if these deliver what you want: https://duckduckgo.com/bang?q=instant https://duckduckgo.com/bang?q=instant You can incorporate bang int commandlinee search, though bangs ("!") generally require quoting to avoid bash / shell interpretation.
- dontbenebby 8y agoAh cool, thanks. Very useful! I meant more like the various cheatsheets. (Ex: https://duckduckgo.com/?q=vim+cheat+sheet 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! :)
- favadi 8y agoWhy would I use this if I will need a proper browser to view the result anyway?
- apjana 8y agoStrictly speaking, you don't need a browser. You can directly print the content of the results in the terminal with the newspaper library. 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`.