Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

vb.net - Extract Text from Response Body in Coded Webtest using vb

I have a Web performance Script in Visual Studio. I have turned this into Coded Webtest in VB by clicking on the Generate Code button.

In my web test there are a 5 functions. Apart from the 1st the others are for SQL Procedures.

Among a few things, I need a web request that does a certain action. Based on that action, In the response body - it generates a Unique Id.

I need this Id to make it accessible across all the functions.

The Response body is something like this :

0x00000000  7B  22  69  64  22  3A  36  35  33  30  36  36  33  7D            {"id":2133221}  

Now I wanted to know, how do I do it. I just need 2133221.

I tried using the Context Parameter name and appending it to a .to string...it did not work. I tried doing by looking over the net and trying out a few options. I'm lost now. Can anyone help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The simplest solution is the below one.

str = "0x00000000 7B 22 69 64 22 3A 36 35 33 30 36 36 33 7D {""id"":2133221}"

arr = Split(str, ":")
strID = Left(arr(1), len(arr(1)) - 1)

msgbox strId

However, If you still need a more robust one, try regex


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...