How can I use Curl to check a website's header information?

Curl is a powerful command-line tool used to transfer data to or from a server. It supports various protocols, including HTTP, HTTPS, FTP, and more. You can use Curl to check a website's header information with a simple command.

Here is how to do it:

  1. Open a terminal window.

  2. Run the following command:

curl -I https://www.example.com

In this command, -I (or --head) tells Curl to fetch only the HTTP-header of the specified URL. Replace https://www.example.com with the URL of the website you want to check.

You should get a response similar to this:

HTTP/2 200 
date: Sat, 29 Jan 2022 16:12:20 GMT
content-type: text/html; charset=UTF-8
server: nginx/1.14.0 (Ubuntu)
x-powered-by: PHP/7.2.34
link: <https://www.example.com/wp-json/>; rel="https://api.w.org/"
link: <https://www.example.com/>; rel=shortlink

The output shows the HTTP status code (200 in this case), the date, the server information, the content type, and other details.

Remember, the -I option makes a HEAD HTTP request, which asks the server to send the response headers only, and not the actual document.

Always ensure that you have the necessary permissions to perform any operations with Curl, especially on websites you do not own. Web scraping and data extraction should respect the website's robots.txt file and terms of service.

Related Questions

Get Started Now

WebScraping.AI provides rotating proxies, Chromium rendering and built-in HTML parser for web scraping
Icon