12
12

More than 5 years have passed since last update.

wget による Googleの検索結果の取得

Posted at

wgetコマンドからの利用法

wget "https://www.google.co.jp/search?q=検索キーワード&ie=UTF-8&oe=UTF-8&num=20" \
--no-check-certificate --user-agent="(`・ω・´)" -O キーワード.html

Google検索のパラメータ
* q: 検索キーワード
* oe: 出力時の文字コード。UTF-8指定
* num: 検索結果の表示件数。デフォルト10を変更時

wget のパラメータ
* --no-check-certificate : サーバ証明書を検証しない
* --user-agent: を指定しないと wget だと弾かれたので
* -O: 出力先ファイル名を指定する

注意?
あんまりリクエスト投げすぎると駄目?
今やるとエラーになってしまうので・・・

具体的には次の用途で利用

Googleウェブマスターツールの検索クエリー(上位)に対して、クリック数の改善を行うため現在の検索結果を確認(タイトル、descriptionなど)する為に利用。

ウェブマスターツールの検索クエリを CSVなどでダウンロード。
ダウンロードして知りたいキーワードを適当に取得して、例えばテキストエディタで

01    キーワード(1)
02    キーワード(2)

とか タブ区切りで作成

s/(.+)\t(.+)/wget "https://www.google.co.jp/search?q=\2&ie=UTF-8&oe=UTF-8&num=20" --no-check-certificate --user-agent="(`・ω・´)" -O \1.html/

置換してコマンド流す。

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12