Get in python what web server is used by a website

Question:

How can I know if a website is using apache, nginx or other and get this information in python? Thanks in advance

Asked By: Ensorid

||

Answers:

This information if available is given in the header of the response to a HTTP Request. With Python you can perform HTTP requests using the module requests.

Make a simple GET request to the interested site and then print the headers parameter of the returned object.

import requests
r = requests.get(YOUR_SITE)
print(r.headers)

The output is made of a dictionary of keys and value, you have to look for the Server parameter

server = r.headers['Server']

You must be aware that not all websites return this information for several reasons, so you could not find this key in the response header.

Answered By: Matteo
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.