wgetを使用して実際のHTMLの代わりにgzipバージョンを取得する正しいコマンドは何ですか?

wgetを使用して実際のHTMLの代わりにgzipバージョンを取得する正しいコマンドは何ですか?

私は偶然偶然発見したこのウェブサイトこれについての言及はありません。

それでは、gzipで圧縮されたバージョンを受け取り、ウェブサイト全体をダウンロードするときに正しいコマンドは何ですか?

このコマンドをテストしましたが、wgetが実際にgzipバージョンを取得しているかどうかはわかりません。

wget --header="accept-encoding: gzip" -m -Dlinux.about.com -r -q -R gif,png,jpg,jpeg,GIF,PNG,JPG,JPEG,js,rss,xml,feed,.tar.gz,.zip,rar,.rar,.php,.txt -t 1 http://linux.about.com/

ベストアンサー1

gzipで圧縮されたコンテンツを要求した場合(正しいAccept-encoding:gzipヘッダを使用)、wgetはコンテンツを読み取ることができないことを理解しています。したがって、クリックした最初のページのディスクには1つのgzipファイルしか残っていません。

つまり、wgetを使用してgzipで圧縮されたコンテンツを要求し、同時にサイト全体を繰り返すことはできません。

これをサポートするwget用のパッチがあると思いますが、デフォルトのディストリビューションにはありません。

-Sフラグを含めると、Webサーバーが正しいコンテンツタイプで応答しているかどうかがわかります。例えば、

wget -S --header="accept-encoding: gzip" wordpress.com
--2011-06-17 16:06:46--  http://wordpress.com/
Resolving wordpress.com (wordpress.com)... 72.233.104.124, 74.200.247.60, 76.74.254.126
Connecting to wordpress.com (wordpress.com)|72.233.104.124|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: nginx
  Date: Fri, 17 Jun 2011 15:06:47 GMT
  Content-Type: text/html; charset=UTF-8
  Connection: close
  Vary: Accept-Encoding
  Last-Modified: Fri, 17 Jun 2011 15:04:57 +0000
  Cache-Control: max-age=190, must-revalidate
  Vary: Cookie
  X-hacker: If you're reading this, you should visit automattic.com/jobs and apply to join the fun, mention this header.
  X-Pingback: http://wordpress.com/xmlrpc.php
  Link: <http://wp.me/1>; rel=shortlink
  X-nananana: Batcache
  Content-Encoding: gzip
Length: unspecified [text/html]

コンテンツエンコーディングにはgzipが明示的に指定されていますが、linux.about.com(現在)の場合

wget -S --header="accept-encoding: gzip" linux.about.com
--2011-06-17 16:12:55--  http://linux.about.com/
Resolving linux.about.com (linux.about.com)... 207.241.148.80
Connecting to linux.about.com (linux.about.com)|207.241.148.80|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Date: Fri, 17 Jun 2011 15:12:56 GMT
  Server: Apache
  Set-Cookie: TMog=B6HFCs2H20kA1I4N; domain=.about.com; path=/; expires=Sat, 22-Sep-12 14:19:35 GMT
  Set-Cookie: Mint=B6HFCs2H20kA1I4N; domain=.about.com; path=/
  Set-Cookie: zBT=1; domain=.about.com; path=/
  Vary: *
  PRAGMA: no-cache
  P3P: CP="IDC DSP COR DEVa TAIa OUR BUS UNI"
  Cache-Control: max-age=-3600
  Expires: Fri, 17 Jun 2011 14:12:56 GMT
  Connection: close
  Content-Type: text/html
Length: unspecified [text/html]

テキスト/htmlを返します。

一部の古いブラウザではまだgzipエンコードコンテンツに問題があるため、多くのWebサイトはブラウザ認識のみに基づいてそれを有効にしています。彼らはしばしばデフォルトでwgetをオフにし、ブラウザがそれをサポートできることを知っている場合にのみオンになり、通常はそのリストにwgetを含めません。これは、ウェブサイトがあなたのブラウザにgzipで圧縮されたコンテンツを返すように見えても、wgetがgzipで圧縮されたコンテンツを返さないことを意味します。

おすすめ記事