【Jmeter篇】后置处理器之边界提取器
我們想從接口中提取一些想用的東西,不習慣用正則提取器和json提取器,今天我們來介紹下邊界提取器,相對前者較簡單些。它通過左右邊界來提取需要的內容,它可以匹配任何格式的內容,如文本、json、xpath、html等等,使用也很簡單,分別填寫要提取內容的左右邊界即可,很靈活
一、添加邊界提取器
線程組—添加—后置處理器—邊界提取器
二、使用邊界提取器提取百度響應中(百度一下,你就知道)
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新聞</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地圖</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>視頻</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>貼吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登錄</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登錄</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多產品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>關于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a href=http://www.baidu.com/duty/>使用百度前必讀</a> <a href=http://jianyi.baidu.com/ class=cp-feedback>意見反饋</a> 京ICP證030173號 <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
三、邊界提取器設置
Apply to: 選Main sample only
要檢查的響應字段? 選主體
引用名稱? 提取出來參數引用的名稱??param
Left Boundary:提取值左邊界? ?<title>
Right Boundary:提取值右邊界? ?</title>
匹配數字? 0隨機1個? ?1取第1個? ? ?1
四、添加Debug Sampler測試是否提取成功
五、提取出來的值當作參數傳參給其它采樣器
總結
以上是生活随笔為你收集整理的【Jmeter篇】后置处理器之边界提取器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Jmeter篇】jmeter+Ant+
- 下一篇: Django连接现有mysql数据库