获取HTTP服务器的服务器头

2024-10-06 12:24:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用Python获取HTTP的Server头。我不知道怎样才能得到它,我看了一下{}的{},进入了{}部分

 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.

我们怎样才能得到它?我可以用osplatform等来猜测


Tags: andthehttpfieldinformationserverresponseproduct
1条回答
网友
1楼 · 发布于 2024-10-06 12:24:10

我假设你想:

  • 向web服务器发送HTTP请求并检索“服务器”标头 从HTTP响应
  • 您想使用python

“requests”是一个非常流行的用于发出HTTP请求的库(https://requests.readthedocs.io/en/master/

下面是一个代码示例,非常有可能指导您实现所需的功能

import requests
response = requests.get("http://example.com")
print(response.headers['Server'])

相关问题 更多 >