无法从JMeter

时间:2015-06-29 09:58:58

标签: regex jmeter

在尝试从JMeter变量中提取正则表达式时,我遇到了JMeter问题。

Test plan

我正在生成http请求并获得以下响应:

  

{"错误":" OK""错误码":0,"数据":[{" AppIconUrl&# 34;:" HTTP://a2.jqzfgh75x175-75.jpg"," AppName的":" 26082014"" AppProviderName":& #34; F"" BannerText":空," BlockedSubAffiliates":["未提供&#34],"关键字":[& #34;游戏""孩子&#34],"素材&#34 ;: [{" CreativeLink":" HTTP://773gffff64ec6cffe3114cf789f9ca381c27e8a0_320x50.jpg&# 34;," CreativeSize":" 320x50的""广告素材类型":"横幅""标识":1234, "名称":" 320x50.jpg"},{" CreativeLink":" HTTP://77312bc1cfc3c281234_320x480.jpg"," CreativeSize":"分辨率320x480""广告素材类型":"全屏""标识" 231"名称&#34 ;:" 320x480.jpg"},{" CreativeLink":" HTTP://77312bc1cfc123452c7f_480x320.jpg"," CreativeSize":&# 34;分辨率480x320""广告素材类型":"全屏""标识":543,"名称":&#34 ; 480x320.jpg"},{" CreativeLink":" HTTP://77312bc1cdgh7w33bc09e_320x480.jpg"," CreativeSize":"分辨率320x480&#34 ;,"广告素材类型":" CompanionBanner""标识":9872,"名称":"未提供"}, {" CreativeLink":" HTTP:// 77312bc1cfcdgdhe555id _320x480.mp4"" CreativeSize":"分辨率320x480""广告素材类型& #34;:"视频""编号":53433,"名称":"孩子_320x480.mp4"}],&#! 34;每日预算乘以":"未提供""说明":"试验   应用"" DeviceIds":[]," IsDeviceIdMandatory":假," MarketAppId":" com.teamlava.candy(试验)& #34;" MinOsVersion":" 2.3""名称":"测试   ý""网络与#34;:[" WIFI"" 3G&#34]," OFFERID":" 75824&#34 ;,"付款":0.00001" PayoutType":" CPM""平台":[" Android和#34;] " PreviewLink":" HTTPS://plndy.com"," SupportedCountries&#34 ;: [" AU"" BR&# 34;," CN"" DE"" IN"" IL"" CH"&# 34; GB"" US&#34]," TrackingLink":" HTTP://clk.test.com/aff_c tt_ls = b和= offer_id&75824安培; aff_id = 12&安培; tt_appid = 12(试验)及tt_bannerid ="},{" AppIconUrl":" HTTP://a2.154qzpnbsu.175x175-75.jpg" " AppName的":" test26082014"" AppProviderName":" Y"" BannerText":空,&# 34; BlockedSubAffiliates":["未提供&#34],"关键字":["游戏""孩子&#34],&#34 ;素材&#34 ;: [{" CreativeLink":" HTTP://7731dfgmkl3428cf_320x50.jpg"," CreativeSize":" 320x50的&#34 ;, "广告素材类型":"横幅""标识":9886555 4,"名称":" 320x50.jpg"},{" CreativeLink":" HTTP://77sdfgklsg0f_320x480.jpg",&# 34; CreativeSize":"分辨率320x480""广告素材类型":"全屏""标识":536372,"名称& #34;:" 320x480.jpg"},{" CreativeLink":" HTTP://7dfgh556a6c_480x320.jpg"," CreativeSize&#34 ;: "分辨率480x320""广告素材类型":"全屏""标识":985442525"名称":&#34 ; 480x320.jpg"},{" CreativeLink":" HTTP://7731grdk4_320x480.jpg"," CreativeSize":"分辨率320x480&#34 ;,"广告素材类型":" CompanionBanner""标识":712,"名称":"未提供"}, {" CreativeLink":" HTTP:// 773tktkoid _320x480.mp4"" CreativeSize":"分辨率320x480""广告素材类型& #34;:"视频""编号":63722,"名称":"投标_320x480.mp4"}],&#! 34;每日预算乘以":"未提供""说明":"试验   APP2"" DeviceIds":[]," IsDeviceIdMandatory":假," MarketAppId":" ABY(试验)&#34 ;, " MinOsVersion":" 2.3""名称":" Test2的   02122014""网络与#34;:[" WIFI"" 3G&#34]," OFFERID":" 3666&#34 ;,"付款":1.00000" PayoutType":" CPC""平台":[" Android和#34;] " PreviewLink":" HTTPS://play.google.com/store/apps/details ID = com.teamlava.candy"" SupportedCountries&#34 ;: [" AU"" BR"" CA"" DE"" IL"" GB"" US&#34]," TrackingLink":" HTTP://clk.taptica.com/aff_c tt_ls = b和= offer_id 3666&安培; aff_id = 12安培; tt_appid = 12(试验)及tt_bannerid ="}]}

当我试图从回复中提取以下正则表达式时身体,它工作正常:

  

正则表达式1:" ErrorCode" :( [0-9] +),|([0-9] +)< / errorCode>

     

结果1:0

regular expression 1

  

正则表达式2:{" AppIconUrl" :(。+?)tt_bannerid ="} | \ n(。+?)\ n | \ n(。+?)$ |( 。+)< /供应>

     

结果2:" http://a2.jqzfgh75x175-75.jpg"," AppName":" 26082014"," AppProviderName&#34 ;:" F"" BannerText":空," BlockedSubAffiliates":["未提供&#34],"关键字" :"游戏""孩子&#34],"素材&#34 ;: [{" CreativeLink":" HTTP:// 773gffff64ec6cffe3114cf789f9ca381c27e8a0_320x50 .JPG"" CreativeSize":" 320x50的""广告素材类型":"横幅""标识" :1234,"名称":" 320x50.jpg"},{" CreativeLink":" HTTP://77312bc1cfc3c281234_320x480.jpg",& #34; CreativeSize":"分辨率320x480""广告素材类型":"全屏""标识" 231"名称":" 320x480.jpg"},{" CreativeLink":" HTTP://77312bc1cfc123452c7f_480x320.jpg"," CreativeSize" :"分辨率480x320""广告素材类型":"全屏""标识":543,"名称":&# 34; 480x320.jpg"},{" CreativeLink":" HTTP:// 77312bc1cdgh7w33bc09e_320 x480.jpg"" CreativeSize":"分辨率320x480""广告素材类型":" CompanionBanner""标识&#34 ;:9872,"名称":"未提供"},{" CreativeLink":" HTTP:// 77312bc1cfcdgdhe555id _320x480.mp4&#34 ;, " CreativeSize":"分辨率320x480""广告素材类型":"视频""标识":53433&#34 ;名称":"孩子_320x480.mp4"}],"每日预算乘以":"不可用""说明":&# 34;测试app"," DeviceIds":[]," IsDeviceIdMandatory":false," MarketAppId":" com.teamlava.candy(测试)"," MinOsVersion":" 2.3","姓名":"测试y","网络& #34;:[" WIFI"" 3G&#34]," OFFERID":" 75824""付款" :0.00001" PayoutType":" CPM""平台":[" Android和#34;]" PreviewLink&#34 ;: " HTTPS://plndy.com"," SupportedCountries&#34 ;: [" AU"" BR"" CN&#34 ;," DE"" IN"" IL"" CH&#3 4;," GB"" US&#34]," TrackingLink":" HTTP://clk.test.com/aff_c tt_ls = B和; offer_id = 75824&安培; aff_id = 12&安培; tt_appid = 12(试验)及

regular expression 2

现在,我试图从结果2中提取以下正则表达式,但由于某种原因它不起作用,我只得到默认值:

  

正则表达式3:(clk。+)&

     

预期结果3:clk.test.com/aff_c?tt_ls=b&offer_id=75824&aff_id=12&tt_appid=12(test)

     

结果3(默认值):empty_click_uri

regular expression 3

  

正则表达式4:" Id" :( [0-9] +)| [id :(。+?)|([0-9] +?)< / Id>

     

预期结果4:1234

     

结果4(默认值):empty_creative_id

enter image description here

我在https://regex101.com/中测试了我的正则表达式,而且一切似乎都运行良好。我无法弄清楚为什么它不会在JMeter上工作。

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

找出它没有工作的原因。

因为JMeter"知道"这些是变量而不是期望字符串,不需要" $"," {"和"}"。

正确的设置是:

correct regular expression 3

correct regular expression 4