1、正则提取器+ForEach控制器+BeanShell PostProcessor+BeanShell 取样器,爬取网站信息并写入到csv中
2、访问网站设置
3、正则提取设置,匹配数字-1代表提取所有符合条件的信息
4、ForEach控制器设置迭代每次提取出来的信息
5、BeanShell PostProcessor设置(5和6用一种即可)
FileWriter fstream=new FileWriter("C:\\jmeter\\apache-jmeter-5.0\\bin\\TestResult\\pcs.csv",true);
BufferedWriter out =new BufferedWriter(fstream);
out.write(vars.get("url"));
out.write(System.getProperty("line.separator"));
out.close();
fstream.close();
6、BeanShell 取样器设置(5和6用一种即可)
FileWriter fstream=new FileWriter("C:/jmeter/apache-jmeter-5.0/bin/TestResult/pc.csv",true);//本地文件路径
BufferedWriter out =new BufferedWriter(fstream);
out.write("${url}");//提取的参数
out.write(",");//换列
out.write("${url}");//提取的参数
out.write(System.getProperty("line.separator"));//换行
out.close();
fstream.close();
7、结果树展示提取的信息
8、BeanShell 取样器,提取信息并保存生成csv