且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将特定数据从响应数据保存到CSV文件

更新时间:2023-01-12 11:37:20

您可以使用Regex后处理器提取数据并将其保存到变量中.

You can extract data using Regex post processor and save it to a variable.

简单的数据写入器,灵活的数据写入器,将结果保存到文件中,所有这些都可以写入预定义的变量,以固定的或一点点可自定义的格式对文件进行响应,但不允许您编写自定义变量.

Simple data writer, Flexible data writer, Save results to a file all these can write predefined variables, responses to a file in a fixed or little bit customizable format but won't let you write your custom variables.

要将其写入文件,您需要使用Beanshell处理器. 示例代码为

For writing it to a file you need to use Beanshell processor. Sample code would be,

username = vars.get("username");
password = vars.get("password");

f = new FileOutputStream("/path/user_details.csv", true);
p = new PrintStream(f); 
this.interpreter.setOut(p); 
print(username + "," + password);
f.close();