我想用 Python 获取 HTTP 的Server
头。我不知道怎么能得到它,我看了Hypertext Transfer Protocol
的RFC
,进入了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.
我可以用os
或platform
等来猜测。
我假设你想:
将 HTTP 请求发送到 Web 服务器,并从 HTTP 响应中检索“Server”标头。
你想使用 python。
'requests' 是一个非常流行的 lib 来发出 HTTP 请求(https://requests.readthedocs.io/en/master/)
这里是一个代码示例非常可以指导你实现你所需要的
import requests
response = requests.get("http://example.com")
print(response.headers['Server'])
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(50条)