> 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.
ddgr 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.
Just 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].
>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.
No, 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.
Google 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).
Are 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:
In 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:
This 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.
Hi, maybe there's something wrong with my environment, but I installed Lynx via brew, got the location (which brew|pbcopy) then exported the location to an environment variable (export BROWSER=/usr/local/bin/lynx).
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 :) )
Can 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
The 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).
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.
n=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.
Strictly 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`.
I 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.
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.