Would you like to learn how to get the HTTP headers using Python? In this tutorial, we are going to show you how to use Python to get headers of an HTTP connection on a computer running Linux.

• Ubuntu 20
• Ubuntu 19
• Ubuntu 18
• Python 3.8.5

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial Python - Get the HTTP headers

Get the HTTP headers using Python.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

In our example, we got the HTTP headers using Python.

Get the HTTP headers as a dictionary.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

Get the HTTP headers without following a redirect.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

In our example, we got the HTTP headers as a Python dictionary.

Get a specific item from the HTTP header.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

In our example, we got the item named DATE from the HTTP header.

Congratulations! You are able to get the HTTP headers using Python.