Apache JMeter正则表达式提取程序错误

时间:2014-10-27 12:17:21

标签: regex apache xmlhttprequest jmeter beanshell

我已经向网页发出了HTTP请求,并且使用VAST代码(XML)成功响应之后我尝试使用Apache JMeter正则表达式提取器从 MediaFile 标签中提取URL响应了XML代码。但它不起作用。

以下是响应数据(VAST XML):

<?xml version="1.0" encoding="UTF-8"?>
<VAST version="2.0">
  <Ad id="brightroll_ad">
    <InLine>
      <AdSystem>BrightRoll</AdSystem>
      <AdTitle></AdTitle>
      <Impression><![CDATA[http://brxserv-22.btrll.com/v1/epix/6835714/3858435/84416/140363/AbQ93_XgMgCcRUTi_JAAFJwAACJEsAOuADAAAAAAAiyel-GCNFFg/event.imp/r_64.aHR0cDovL2Iuc2NvcmVjYXJkcmVzZWFyY2guY29tL3A_JmMxPTgmYzI9NjAwMDAwNiZjMz04NDQxNiZjND0zODU4NDM1JmM1PTIwNDYzJmM2PTY4MzU3MTQmYzEwPTE0MDM2MyZjdj0xLjcmY2o9MSZybj0xNDE0NDEwMTg1JnI9aHR0cCUzQSUyRiUyRnBpeGVsLnF1YW50c2VydmUuY29tJTJGcGl4ZWwlMkZwLWNiNkMwekZGN2RXakkuZ2lmJTNGbGFiZWxzJTNEcC42ODM1NzE0LjM4NTg0MzUuMCUyQ2EuMjA0NjMuODQ0MTYuMTQwMzYzJTJDdS45NjguNjQweDM2MCUzQm1lZGlhJTNEYWQlM0JyJTNEMTQxNDQxMDE4NQ]]></Impression>
  <Impression><![CDATA[http://rc.rlcdn.com/361686.gif]]></Impression>
  <Creatives>
    <Creative id="140363" sequence="1">
      <Linear>
        <Duration>00:00:30</Duration>
        <TrackingEvents>
          <Tracking event="midpoint"><![CDATA[http://brxserv-22.btrll.com/v1/epix/6835714/3858435/84416/140363/AbQ93_XgMgCcRUTi_JAAFJwAACJEsAOuADAAAAAAAiyel-GCNFFg/event.mid]]></Tracking>
          <Tracking event="complete"><![CDATA[http://brxserv-22.btrll.com/v1/epix/6835714/3858435/84416/140363/AbQ93_XgMgCcRUTi_JAAFJwAACJEsAOuADAAAAAAAiyel-GCNFFg/event.end]]></Tracking>
        </TrackingEvents>
        <AdParameters></AdParameters>
        <VideoClicks>
          <ClickTracking><![CDATA[http://brxserv-22.btrll.com/v1/epix/6835714/3858435/84416/140363/AbQ93_XgMgCcRUTi_JAAFJwAACJEsAOuADAAAAAAAiyel-GCNFFg/event.click]]></ClickTracking>
        </VideoClicks>
        <MediaFiles>
          <MediaFile type="application/x-shockwave-flash" apiFramework="VPAID" height="360" width="640" delivery="progressive">
            <![CDATA[http://shim.btrll.com/shim/20141023.75835_master/Scout.swf?type=VPAID&hidefb=true&asset_64=aHR0cDovL3J0ci5pbm5vdmlkLmNvbS9yMS41NDQ1OTU0ZDA5ZTY4OS40MjIxNTcxODtjYj0xNDE0NDEwMTg1O3NpdGVpZD0zODU4NDM1bGluZWl0ZW04NDQxNg&vid_click_url=&config_url_64=&h_64=YnJ4c2Vydi0yMi5idHJsbC5jb20&dn=-&e=p&p=6835714&s=3858435&l=84416&ic=140363&ii=20463&iq=t&cx=&x=AbQ93_XgMgCcRUTi_JAAFJwAACJEsAOuADAAAAAAAiyel-GCNFFg&adc=false&t=33&si=&vh_64=Z2VvLXJ0YnNlcnYtdjIuYnRybGwuY29t&apep=0.05&hbp=0.01&view=vast2]]>
          </MediaFile>
        </MediaFiles>
      </Linear>
    </Creative>
  </Creatives>
</InLine>

以下是我使用过的设置。

Reference Name: mediaFileUrl_VASTAdTagURI
Regular Expression: <MediaFile type="application//x-shockwave-flash" apiFramework="VPAID" height="360" width="640" delivery="progressive"><([^"]+)http:\/\/([^"]+)]]>>
Template: $1$$2$
Match No.: -1
Default Value: No mediaFileUrl_VASTAdTagURI

结果始终为(无mediaFileUrl_VASTAdTagURI)。关于正则表达式问题的任何线索。

1 个答案:

答案 0 :(得分:0)

JMeter提供XPath Extractor来处理XML和XHTML数据。它也适用于HTML,但您必须检查Use Tidy框,以便JMeter可以使用JTidy来处理HTML。

提取CDATA内容的XPath表达式应该类似于:

//MediaFile/text()[2]

有关详细信息,请参阅XPath Tutorial。很少有工具可以帮助构建/调试XPath表达式: