サーバーのよく使うコマンドメモ|wget

2015年2月6日

コマンド サーバー テクノロジー

Summery

別サーバー情報をぶっこ抜く便利なコマンド。 クローラーシステムを構築する時に使用すると便利。

Construction

$ wget [option] [URL] ※上記で%URL%が通常の「http://***/index.html」であれば、"index.html"というファイルにページソースのhtmlがDLされる。

Option

-l : 階層指定 -r : 再帰的に行う -i : 階層を保持する -0 : DLしない -4 : IPv4 -6 : IPv6 -O : 出力ファイル名(出力しない場合は「-」) -q : 出力表示を無くす -i : URL一覧ファイルを読みこむ -x : ドメインディレクトリを作成する -w : ダウンロード間隔 -H : 他のドメインのリンクをたどる(デフォルトは同一ドメインのみ) --spider : ダウンロードせずに、存在確認を行う。

Sample

# 階層指定の場合 *3階層限定 $ wget -l 3 http://yahoo.co.jp/ # サイトまるごとぶっこ抜き *root階層を入れるといいが、アクセス先サーバーに負荷がかかるので、お気をつけて $ wget -r http://hoge.com/ # ファイルpathを自動取得してDL $ wget -i http://huga.com/ # ファイルを生成せずにソースをその場で表示 $ wget -O - http://google.com/

参考

http://blog.layer8.sh/ja/2012/03/31/wget_command/

Discription

GNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies. Wget is non-interactive, meaning that it can work in the background, while the user is not logged on. This allows you to start a retrieval and disconnect from the system, letting Wget finish the work. By contrast, most of the Web browsers require constant user's presence, which can be a great hindrance when transferring a lot of data. Wget can follow links in HTML, XHTML, and CSS pages, to create local versions of remote web sites, fully recreating the directory structure of the original site. This is sometimes referred to as "recursive downloading." While doing that, Wget respects the Robot Exclusion Standard (/robots.txt). Wget can be instructed to convert the links in downloaded files to point at the local files, for offline viewing. Wget has been designed for robustness over slow or unstable network connections; if a download fails due to a network problem, it will keep retrying until the whole file has been retrieved. If the server supports regetting, it will instruct the server to continue the download from where it left off.

このブログを検索

ごあいさつ

このWebサイトは、独自思考で我が道を行くユゲタの少し尖った思考のTechブログです。 毎日興味がどんどん切り替わるので、テーマはマルチになっています。 もしかしたらアイデアに困っている人の助けになるかもしれません。