python获取网页响应时间
python里可以获取网页响应时间的方法
这个方法需要用到requests包
获取到的时间单位为微秒
想要获取其他时间单位,可以自己按规则转换
以下代码是获取到了毫秒
#! /usr/bin/python
# coding: utf-8
import requests
r = requests.get("http://www.baidu.com")
a = r.elapsed.microseconds/1000
print a
python获取网页响应时间
python里可以获取网页响应时间的方法
这个方法需要用到requests包
获取到的时间单位为微秒
想要获取其他时间单位,可以自己按规则转换
以下代码是获取到了毫秒
#! /usr/bin/python
# coding: utf-8
import requests
r = requests.get("http://www.baidu.com")
a = r.elapsed.microseconds/1000
print a