python 探测web服务质量方法
来源:互联网 发布:西安万科金域名城 编辑:程序博客网 时间:2024/05/22 12:57
python3脚本如下:
#!/usr/local/bin/python3#-*- coding: utf-8 -*-import osimport timeimport sysimport pycurlURL="http://www.baidu.com"c = pycurl.Curl()c.setopt(pycurl.URL, URL)c.setopt(pycurl.CONNECTTIMEOUT, 5)c.setopt(pycurl.TIMEOUT, 5)c.setopt(pycurl.NOPROGRESS, 1)c.setopt(pycurl.FORBID_REUSE, 1)c.setopt(pycurl.MAXREDIRS, 1)c.setopt(pycurl.DNS_CACHE_TIMEOUT,30)indexfile = open(os.path.dirname(os.path.realpath(__file__)) + "/content.txt","wb")c.setopt(pycurl.WRITEHEADER, indexfile)c.setopt(pycurl.WRITEDATA, indexfile)try: c.perform()except Exception as e: print ("connecion error:"+str(e)) indexfile.close() c.close() sys.exit()NAMELOOKUP_TIME = c.getinfo(c.NAMELOOKUP_TIME)CONNECT_TIME = c.getinfo(c.CONNECT_TIME)PRETRANSFER_TIME = c.getinfo(c.PRETRANSFER_TIME)STARTTRANSFER_TIME = c.getinfo(c.STARTTRANSFER_TIME)TOTAL_TIME = c.getinfo(c.TOTAL_TIME)HTTP_CODE = c.getinfo(c.HTTP_CODE)SIZE_DOWNLOAD = c.getinfo(c.SIZE_DOWNLOAD)HEADER_SIZE = c.getinfo(c.HEADER_SIZE)SPEED_DOWNLOAD=c.getinfo(c.SPEED_DOWNLOAD)#打印数据print ("HTTP状态码:%s" %(HTTP_CODE))print ("DNS解析时间:%.2f ms"%(NAMELOOKUP_TIME*1000))print ("建立连接时间:%.2f ms"%(CONNECT_TIME*1000))print ("准备传输时间:%.2f ms"%(PRETRANSFER_TIME*1000))print ("传输开始时间:%.2f ms"%(STARTTRANSFER_TIME*1000))print ("传输结束总时间:%.2f ms"%(TOTAL_TIME*1000))print ("下载数据包大小:%d bytes/s"%(SIZE_DOWNLOAD))print ("HTTP头部大小:%d byte" %(HEADER_SIZE))print ("平均下载速度:%d bytes/s"%(SPEED_DOWNLOAD))indexfile.close()c.close
阅读全文
0 0
- python 探测web服务质量方法
- python探测web服务质量
- Python学习笔记-实现探测Web服务质量
- 【Python】检测Web服务质量
- 使用Python 2.7中pycurl模块编写探测多节点Web服务质量脚本
- 检测web服务质量
- pycurl+web服务质量检测
- python 服务器状态探测3种方法
- Python 探测图片文件类型
- 【Python】Struct2 探测工具
- 8.数据库探测方法
- whatweb WEB指纹探测工具
- 4.2web漏洞扫描探测
- 避免网络应用死机,崩溃,保证服务质量的一般方法
- 去掉移动web页面自动探测电话号码
- 探测python中字符集模块chardet
- QOS服务质量
- QoS服务质量
- python第三方库下载网址
- poj1915 Knight Moves(bfs)
- js全选
- 设计模式 单例模式
- java正则表达式匹配固定位数的数字
- python 探测web服务质量方法
- Chrome调试技巧
- zookeeper配置中出现Error contacting service. It is probably not running
- Python中进程池的相关概念
- POJ 3176 Cow Bowling
- 服务器运行打包的jar
- vue中引入bootstrap
- php 测试
- Springboot集成thymeleaf