GNU/Linux >> Linux の 問題 >  >> Linux

cURLでヘッダー情報を取得する

ウェブサイトのヘッダーをテストできるオンラインツールはたくさんあります。ただし、ローカルツール( cURL )を使用して1つのサイトのヘッダーを確認する簡単な方法があります。 。 cURL (クライアントURL)は、さまざまなプロトコルを介して情報を転送するためのツールです。

この例では、これを使用して特定のサイトのヘッダーを取得します。コマンドは次のとおりです。

# curl -L -I domain.com
-L, --location	- cURL will follow any redirections
-I, --head	- cURL will get only the headers of the document

ドメイン名の例を以下に示します。ツールがヘッダーのみを取得しており、plothost.comからhttps://www.plothost.com

へのリダイレクトにも従っていることがわかります。
root@web [~]# curl -L -I plothost.com
HTTP/1.1 301 Moved Permanently
Date: Wed, 13 May 2020 17:14:14 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Location: https://www.plothost.com/
Cache-Control: max-age=3600
Expires: Wed, 13 May 2020 18:14:14 GMT
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 200 OK
Date: Wed, 13 May 2020 17:14:15 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Last-Modified: Wed, 13 May 2020 16:43:54 GMT
ETag: "be9b-5a58a49253bdc"
Accept-Ranges: bytes
Content-Length: 48795
Cache-Control: max-age=10800, must-revalidate, public
Expires: Wed, 13 May 2020 17:43:54 GMT
Vary: Accept-Encoding,Cookie
Connection: keep-alive
Set-Cookie: HttpOnly;Secure
X-XSS-Protection: 1; mode=block
Referrer-Policy: no-referrer-when-downgrade
Expect-CT: enforce;max-age=30; report-uri https://plothost.report-uri.io/r/default/ct/enforce
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
Feature-Policy: accelerometer none;ambient-light-sensor none;autoplay none;camera none;geolocation none;gyroscope none;magnetometer none;microphone none;midi none;usb none;vibrate none;wake-lock none;xr-spatial-tracking none
Access-Control-Allow-Origin: *
Pragma: public
Content-Type: text/html; charset=UTF-8

root@web [~]#

リソース:

cURLのマニュアルページ


Linux
  1. LinuxでNetworkManagerを使い始める

  2. クラウドサーバーを使い始める

  3. DebianでTaskselを使い始める

  1. コマンドラインでsortを使用してソートする

  2. Linux で Latex を使い始める

  3. cURL を悪用して Redis と通信する

  1. Linuxを始める10の方法

  2. 行番号情報を含む gcc を使用して C++ のスタック トレースを取得するにはどうすればよいですか?

  3. node.js を使用してシステム統計を取得する方法