Maybe everyone else already knows this, but I just discovered that DuckDuckGo has an API with hooks into our favorite scripting languages! If we install the Perl, Python, and Ruby modules
$ cpanm WWW::DuckDuckGo $ pip install duckduckgo $ gem install duck-duck-go
then we can write Perl
#!/usr/bin/env perl use v5.14; use warnings; use WWW::DuckDuckGo; my $zci = WWW::DuckDuckGo->new->zci(@ARGV); say $zci->heading; say $zci->abstract_text;
Python
#!/usr/bin/env python import duckduckgo import sys zci = duckduckgo.query(' '.join(sys.argv[1:])) print(zci.heading) print(zci.abstract.text)
or Ruby
#!/usr/bin/env ruby require "duck_duck_go" zci = DuckDuckGo.new.zeroclickinfo(ARGV.join(' ')) puts zci.heading puts zci.abstract_text
that we could run like so
$ ./ddg Venture Bros The Venture Bros. The Venture Bros. is an American animated television series that premiered on Cartoon Network's Adult Swim on February 16, 2003.
There is also App::DuckDuckGo, which gives us a duckduckgo command that we could use along with the usual command line tools like grep
$ cpanm App::DuckDuckGo ... $ duckduckgo 'Venture Bros' | grep Venture The Venture Bros. (article) Description: The Venture Bros. is an American animated television series that premiered on Cartoon Network's Adult Swim on February 16, 2003. (Wikipedia) Source: https://en.wikipedia.org/wiki/The_Venture_Bros.
I'm guessing any of these is going to be a lot more fun to play with than a browser!
Recent Comments