Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get in python what web server is used by a website

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading