LinuxでWebサイトをダウンロードする方法(wget)

Linux(wget)でWebサイトをダウンロードする方法

wgetは、LinuxでWebサイトをダウンロードするのに便利なコマンドです。 たとえば、wget [url]

[example@snake ~]$ wget -r -p -k -E http://www.google.com
--2009-07-19 14:07:27--  http://www.google.com/
Resolving www.google.com... 64.233.189.104
Connecting to www.google.com|64.233.189.104|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.google.com.my/ [following]
--2009-07-19 14:07:27--  http://www.google.com.my/
Resolving www.google.com.my... 64.233.189.147
Connecting to www.google.com.my|64.233.189.147|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `www.google.com.my/index.html'

    [ <=>                                   ] 5,742       --.-K/s   in 0.05s

2009-07-19 14:07:27 (102 KB/s) - `www.google.com.my/index.html' saved [5742]

FINISHED --2009-07-19 14:07:27--
Downloaded: 1 files, 5.6K in 0.05s (102 KB/s)
Converting www.google.com.my/index.html... 0-12
Converted 1 files in 0.001 seconds.

上記のコマンドは、「google.com」ウェブサイトをローカルドライブにダウンロードします。

Wgetオプションの説明

-r、–recursiveは再帰的ダウンロードを指定します。
-k、–convert-linksはダウンロードされたHTML内のリンクをローカルファイルにポイントします。
-p、–page-requisitesはすべての画像を取得します。 HTMLページを表示するために必要です。
-E、–html-extensionは、拡張子が「.html」のHTMLドキュメントを保存します。

wgetにはまだ多くの便利なオプションがあります。他のオプションの詳細については、man wgetまたはwget –helpを発行してください。