Home > Mobile >  Get in python what web server is used by a website
Get in python what web server is used by a website

Time:10-21

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

CodePudding user response:

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.

  • Related