美文网首页
【python3-1】读取jmeter报告内容

【python3-1】读取jmeter报告内容

作者: _王子_ | 来源:发表于2019-03-02 15:23 被阅读0次

jmeter生成报告结果

接口测试报告

由于jmeter生成报告的方式是内部引用变量,无法从某个节点取到对应数值,只能通过读取报告数值,然后取出来作为python请求接口的变量参数使用。

查看报告样式

报告样式源码

python读取报告指定内容方法

import urllib
import http.cookiejar
from urllib import request
from bs4 import BeautifulSoup
 
# 读取本地报告html文件
path = 'D:\\ant\\ResultReport\\html\\接口测试报告201902260414.html'

 
with open(path, 'r',encoding='utf-8') as f:
    Soup = BeautifulSoup(f.read(), 'lxml')
    titles = Soup.select('html > body > table > .Failure > td')
 
lists = []
for title in titles:
     lists.append(title.text)

print(lists)

执行脚本,查看返回结果


获取html文件结果

根据python数组,打印对应需要的返回值即可


打印取值结果

相关文章

网友评论

      本文标题:【python3-1】读取jmeter报告内容

      本文链接:https://www.haomeiwen.com/subject/unceuqtx.html