查看网页服务器搭建方式(Python3)

通过方式
通过urllib.request.urlopen()返回的response对象中的getheader(‘Server’)这个函数进行实现。

实例一

>>> import urllib
>>> import urllib.request
>>> response = urllib.request.urlopen('http://www.python.org')
>>> print(response.getheader('Server'))
nginx

实例二

>>> import urllib
>>> import urllib.request
>>>> response = urllib.request.urlopen('http://www.baidu.com')
>>> print(response.getheader('Server'))
BWS/1.1

猜你喜欢

转载自blog.csdn.net/a19990412/article/details/80330154
今日推荐