Trace HTTP requests and gather performance metrics.
pip install tractus
from tractus import Tracer
result = Tracer('https://google.com').trace()
print(f'Host IP: {result.ip}')
print(f'Status code: {result.status_code}')
print(f'DNS time: {result.dns} ms')
print(f'Handshake time: {result.handshake} ms')
print(f'First byte time: {result.first_byte} ms')
print(f'Full body time: {result.full_data} ms')
print(f'Body length: {result.data_length} bytes')
print(f'Headers length: {result.headers_length} bytes')
# Get result as json
result.as_json()
# Get result as dict
result.as_dict()
MIT