Python 获取HTTP服务器的服务器头
我想用Python获取HTTP的Python 获取HTTP服务器的服务器头,python,http,Python,Http,我想用Python获取HTTP的服务器头。我不知道如何获取它,我查看了超文本传输协议的RFC,进入了服务器部分 The Server response-header field contains information about the software used by the origin server to handle the request. The field can contain multiple product tokens (section 3.8) and c
服务器头。我不知道如何获取它,我查看了超文本传输协议的RFC
,进入了服务器
部分
The Server response-header field contains information about the
software used by the origin server to handle the request. The field
can contain multiple product tokens (section 3.8) and comments
identifying the server and any significant subproducts. The product
tokens are listed in order of their significance for identifying the
application.
我们怎样才能得到它?我可以猜测,使用操作系统
或平台
,等等。我假设您想要:
- 向web服务器发送HTTP请求并检索“服务器”标头
从HTTP响应
- 您想使用python
“requests”是一个非常流行的用于生成HTTP请求的库()
下面是一个代码示例,非常有可能指导您实现所需的功能
import requests
response = requests.get("http://example.com")
print(response.headers['Server'])
您如何发出HTTP请求?@klauds。我构建了自己的http服务器,我想在响应标题中包含server
标题,这与您的问题正好相反。为什么是fam?您的问题是如何获取作为客户端任务的服务器头,您的评论是如何设置作为服务器任务的服务器头。