如何阻止 GET 请求的响应

问题描述 投票:0回答:1

我正在使用 python requests 库。我have 向网站发送 GET 请求。响应主体的权重很大,我使用代理并按 GB 付费。我需要阻止代理服务器接收响应以节省带宽。我无法使用 head 请求,因为它们受到网站的限制。

我能找到的所有内容都是从内存中丢弃响应正文,但这与我的问题无关。

http python-requests proxy http-proxy get-request
1个回答
0
投票

如果您不想接收任何内容,为什么要发送 GET 请求?您真的想接收一些不同的信息吗?

例如,如果您只是想测试站点是否已启动,您可以按照如何在 python 中 ping

使用 ping
import os
hostname = "google.com" #example
response = os.system("ping -c 1 " + hostname)
#and then check the response...
if response == 0:
    print(f"{hostname} is up!")
else:
    print(f"{hostname} is down!")
© www.soinside.com 2019 - 2024. All rights reserved.