Measure website load time with Python requests

前端 未结 2 1096
心在旅途
心在旅途 2020-12-24 10:53

I\'m trying to build a tool for testing the delay of my internet connection, more specifically web site load times. I thought of using the python requests module for the loa

2条回答
  •  借酒劲吻你
    2020-12-24 11:18

    As for your question, it should be the total time for

    1. time to create the request object
    2. Send request
    3. Receive response
    4. Parse response (See comment from Thomas Orozco )

    Other ways to measure a single request load time is to use urllib:

    nf = urllib.urlopen(url)
    start = time.time()
    page = nf.read()
    end = time.time()
    nf.close()
    # end - start gives you the page load time
    

提交回复
热议问题