Google検索のgooglerのようにターミナル上でDuckDuckGo検索が出来るddgr

GooglerというターミナルでGoogle検索の出来るgooglerJというコマンドがあります.便利なのですが,自分はDuckDuckGoをメインに利用しています.DuckDuckGoを端末で利用する場合,こんな感じで検索していました. w3m https://html.duckduckgo.com/html?q=クエリー 🏛️
ターミナルアプリケーション紹介サイトのTerminalTriveで今週のおすすめにDuckDuckGo版googler的なddgrが紹介されていたので試してみました.

View on Mastodon



導入

ddgrはPython製でPython 3.8以降が必要です.
各種パッケージマネージャでも配布されています.snapやPyPIが汎用的でしょうか.

DebianやUbuntuではこんな感じ.

$ rmadison ddgr
ddgr       | 1.6-1         | oldoldstable | source, all
ddgr       | 1.9-2         | oldstable    | source, all
ddgr       | 2.1-1         | stable       | source, all
ddgr       | 2.2-1         | testing      | source, all
ddgr       | 2.2-1         | unstable     | source, all
$ rmadison ddgr -u ubuntu
 ddgr | 1.2-1                     | bionic/universe   | source, all
 ddgr | 1.7+git20190928.bccdc92-2 | focal/universe    | source, all
 ddgr | 1.9-2                     | jammy/universe    | source, all
 ddgr | 2.2-1                     | noble/universe    | source, all
 ddgr | 2.2-1                     | oracular/universe | source, all
 ddgr | 2.2-1                     | plucky/universe   | source, all

今回最新の2.2のパッケージのあるDebian sid環境にディストリビューションパッケージから導入しました.

$ apt show ddgr

Package: ddgr
Version: 2.2-1
Priority: optional
Section: misc
Maintainer: SZ Lin (林上智) <szlin@debian.org>
Installed-Size: 132 kB
Depends: python3:any, python3 (>= 3.5)
Homepage: https://github.com/jarun/ddgr
Download-Size: 37.3 kB
APT-Manual-Installed: yes
APT-Sources: http://ftp.jp.debian.org/debian sid/main amd64 Packages
Description: DuckDuckGo from the terminal
Features
.
– Fast and clean (no ads, stray URLs or clutter), custom color
– Navigate result pages from omniprompt, open URLs in browser
– Search and option completion scripts for Bash, Zsh and Fish
– DuckDuckGo Bang support (along with completion)
– Open the first result directly in browser (as in I’m Feeling Ducky)
– Non-stop searches: fire new searches at omniprompt without exiting
– Keywords (e.g. filetype:mime, site:somesite.com) support
– Specify region, disable safe search
– HTTPS proxy support, Do Not Track set, optionally disable User Agent
– Support custom url handler script or cmdline utility
– Comprehensive documentation, man page with handy usage examples
– Minimal dependencies

$ sudo apt install ddgr
$ ddgr -h
usage: ddgr [-h] [-n N] [-r REG] [--colorize [{auto,always,never}]] [-C] [--colors COLORS] [-j] [-t SPAN] [-w SITE] [-x] [-p URI]
            [--unsafe] [--noua] [--json] [--gb] [--np] [--rev] [--url-handler UTIL] [--show-browser-logs] [-v] [-d]
            [KEYWORD ...]

DuckDuckGo from the terminal.

positional arguments:
  KEYWORD               search keywords

options:
  -h, --help            show this help message and exit
  -n N, --num N         show N (0<=N<=25) results per page (default 10); N=0 shows actual number of results fetched per page
  -r REG, --reg REG     region-specific search e.g. 'us-en' for US (default); visit https://duckduckgo.com/params
  --colorize [{auto,always,never}]
                        whether to colorize output; defaults to 'auto', which enables color when stdout is a tty device; using
                        --colorize without an argument is equivalent to --colorize=always
  -C, --nocolor         equivalent to --colorize=never
  --colors COLORS       set output colors (see man page for details)
  -j, --ducky           open the first result in a web browser; implies --np
  -t SPAN, --time SPAN  time limit search [d (1 day), w (1 wk), m (1 month), y (1 year)]
  -w SITE, --site SITE  search sites using DuckDuckGo
  -x, --expand          Show complete url in search results
  -p URI, --proxy URI   tunnel traffic through an HTTPS proxy; URI format: [http[s]://][user:pwd@]host[:port]
  --unsafe              disable safe search
  --noua                disable user agent
  --json                output in JSON format; implies --np
  --gb, --gui-browser   open a bang directly in gui browser
  --np, --noprompt      perform search and exit, do not prompt
  --rev, --reverse      list entries in reversed order
  --url-handler UTIL    custom script or cli utility to open results
  --show-browser-logs   do not suppress browser output (stdout and stderr)
  -v, --version         show program's version number and exit
  -d, --debug           enable debugging

omniprompt keys:
  n, p, f               fetch the next, prev or first set of search results
  index                 open the result corresponding to index in browser
  o [index|range|a ...] open space-separated result indices, ranges or all
  O [index|range|a ...] like key 'o', but try to open in a GUI browser
  d keywords            new DDG search for 'keywords' with original options
                        should be used to search omniprompt keys and indices
  x                     toggle url expansion
  c index               copy url to clipboard
  q, ^D, double Enter   exit ddgr
  ?                     show omniprompt help
  *                     other inputs are considered as new search keywords

Version 2.2
Copyright © 2016-2024 Arun Prakash Jana <engineerarun@gmail.com>
License: GPLv3
Webpage: https://github.com/jarun/ddgr

利用例

普通に検索
$ ddgr 検索キーワード

 1.  ラッコキーワード|無料のキーワード分析ツール(サジェスト・共起語・月間検索数など) [rakkokeyword.com]
     ラッコキーワードは、検索キーワードを入力するとサジェスト、共起語、月間検索数などの情報を提供するキーワードリサーチツールです。個人利用や有料プランで利用できる機能や料金プラン、マニュ
     アルなどの情報もあります。

 2.  【2024年最新】SEOに効く!無料&有料キーワードツール17選 [mieru-ca.com]
     キーワードツールは、Webサイトへのアクセス数を増やすためのSEO対策において
     ユーザーが検索エンジンで入力するキーワードを調査・分析するためのツールです。この記事では、キーワードツールの使い方や重要性、有料&無料のおすすめキーワードツールなどをご紹介します。

 3.  【検索キーワード】の調べ方・選定方法・効果的な活用のしかたを徹底解説 [www.conoha.jp]
     ブログやアフィリエイトサイトの収益化には検索キーワードの選定が重要です。この記事では、検索キーワードの種類や選定方法、検索ボリュームの調べ方、おすすめのツールなどを徹底解説します。

 4.  Google トレンド [trends.google.co.jp]
     Google トレンドは、Google
     検索のデータを分析して、話題になっているキーワードやイベントを表示するサービスです。地域や時間帯、カテゴリーなどで検索キーワードを調べたり、トレンドデータを活用したりできます。

 5.  【2024年最新版】おすすめキーワードツール17選!無料版・有料版の違いも紹介 [www.seohacks.net]
     キーワードツールは、SEOに必要な検索ボリュームや関連キーワードなどを分析できるツールです。この記事では、総合的なツールからサジェストキーワードやトレンドキーワードに特化したツールまで、
     無料版と有料版の違いや使い方を詳しく解説します。

 6.  2024年版:無料のキーワード調査ツール10選 - Ahrefs [ahrefs.jp]
     SEOに役立つキーワード調査の方法とツールを紹介する記事です。AhrefsのキーワードジェネレーターやGoogleトレンドなど、無料で使えるツールの特徴と活用方法を解説します。

 7.  キーワードツール16選!キーワードプランナーの代わりの選定ツールなど無料から紹介|ディーボのSEOラボ [seolaboratory.jp]
     キーワードツールとは、キーワードの競合性や検索ボリューム、関連キーワードなどがわかるSEOツールです。この記事では、キーワードプランナーの代わりとして人気のキーワードツールを16個厳選し、
     機能や料金などを一覧で比較して紹介します。

 8.  無料キーワードジェネレーターツール:数秒で100以上のキーワード候補を見つけましょう [ahrefs.com]
     一日中、キーワード候補を探しましょう. 80億以上のクエリからなる 当社のデータベース から、関連キーワードを検索しましょう。.
     最大10個の単語またはフレーズを入力し、6つのキーワード候補レポートの中から1つを選択するだけです。. 数週間、数ヶ月 ...

 9.  無料のキーワード調査ツール10選(Googleキーワードプランナー以外のもの) | Ahrefsブログ- 使えるSEO情報をお届け | SEO ... [ahrefs.jp]
     Googleキーワードプランナー以外の無料のキーワード調査ツールを紹介します。Googleトレンド、Ahrefsキーワードジェネレーター、Keyword
     Sheeterなど、検索ボリュームやコンペティション、関連キーワードなどの情報を得ることができます。

 10. SEOキーワード調査の手順を徹底解説 - Kinsta [kinsta.com]
     SEOに効果的なキーワードを見つけるための手順と、おすすめの分析ツールを解説します。キーワードの難易度、検索ボリューム、ユーザーの意図などを把握し、ビジネスに有益なキーワードを選択するコ
     ツを学びましょう。

ddgr (? for help) ?

omniprompt keys:
  n, p, f               fetch the next, prev or first set of search results
  index                 open the result corresponding to index in browser
  o [index|range|a ...] open space-separated result indices, ranges or all
  O [index|range|a ...] like key 'o', but try to open in a GUI browser
  d keywords            new DDG search for 'keywords' with original options
                        should be used to search omniprompt keys and indices
  x                     toggle url expansion
  c index               copy url to clipboard
  q, ^D, double Enter   exit ddgr
  ?                     show omniprompt help
  *                     other inputs are considered as new search keywords

ddgr (? for help) 1 (1)
ddgr (? for help) d 猫 季語 (2)

 1.  季語として表現される猫たち 春や冬の季語や猫の俳句を詠んだ俳人たちを紹介 | ペトコト(Petokoto) [petokoto.com]
     猫が春の季語として使われる理由や、猫に関する有名な俳句や猫の恋について紹介するペトコトの記事です。猫の季語や猫の俳句を知りたい方はぜひご覧ください。
  (以下省略)
$ ddgr -n5 検索キーワード (3)
$ ddgr -j ddgr DuckDuckGo (4)
  1. 1件目の検索結果をデフォルトのウェブブラウザで開く

  2. 別の検索キーワード

  3. 検索結果が画面に収まらないので1ページ5件に

  4. 検索結果の一件目を開く

ddgrの検索結果を特定のウェブブラウザで使う

ddgr は環境変数 BROWSER を認識するのでこれを指定することでddgrの検索結果をデフォルト以外のウェブブラウザで開くことが出来ます,端末で動作するw3mやlynxなどのテキストブラウザであれば同じ端末の中で起動して,ウェブブラウザを終了するとまたddgrに戻ってきます.

$ BROWSER=dillo ddgr -n5 検索キーワード (1)
$ BROWSER=w3m ddgr -n5 検索キーワード (2)
  1. ウェブブラウザに軽量なdilloを利用

  2. ウェブブラウザにテキストブラウザのw3mを利用

tor経由で利用

torifyやtorsocksを挟んでtor経由で利用したりも.

$ BROWSER=w3m torify ddgr -n5 site:torproject.org check
$ BROWSER=w3m torsocks ddgr -j site:torproject.org check

便利に使えそうです :)

環境
$ dpkg-query -W ddgr w3m tor torsocks dillo
ddgr    2.2-1
dillo   3.0.5-7.1
tor     0.4.8.13-2
torsocks        2.4.0-2
w3m     0.5.3+git20230121-2+b3
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64

One thought to “Google検索のgooglerのようにターミナル上でDuckDuckGo検索が出来るddgr”

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)