html解析在列中使用perl查找提取值

时间:2017-08-03 10:43:55

标签: html perl html-parsing haproxy

HH:mm:ss

大家好我想使用perl来解析haproxy页面卷曲的结果..我想在某些列中获取infor,如下所示:

<table class="tbl" width="100%">
<tr class="titre"><th rowspan=2></th><th colspan=3>Queue</th><th colspan=3>Session rate</th><th colspan=6>Sessions</th><th colspan=2>Bytes</th><th colspan=2>Denied</th><th colspan=3>Errors</th><th colspan=2>Warnings</th><th colspan=9>Server</th></tr>
<tr class="titre"><th>Cur</th><th>Max</th><th>Limit</th><th>Cur</th><th>Max</th><th>Limit</th><th>Cur</th><th>Max</th><th>Limit</th><th>Total</th><th>LbTot</th><th>Last</th><th>In</th><th>Out</th><th>Req</th><th>Resp</th><th>Req</th><th>Conn</th><th>Resp</th><th>Retr</th><th>Redis</th><th>Status</th><th>LastChk</th><th>Wght</th><th>Act</th><th>Bck</th><th>Chk</th><th>Dwn</th><th>Dwntme</th><th>Thrtle</th>
</tr><tr class="frontend"><td class=ac><a name="stats/Frontend"></a><a class=lfsb href="#stats/Frontend">Frontend</a></td><td colspan=3></td><td><u>1<div class=tips><table class=det><tr><th>Current connection rate:</th><td>1/s</td></tr><tr><th>Current session rate:</th><td>1/s</td></tr><tr><th>Current request rate:</th><td>1/s</td></tr></table></div></u></td><td><u>4<div class=tips><table class=det><tr><th>Max connection rate:</th><td>4/s</td></tr><tr><th>Max session rate:</th><td>4/s</td></tr><tr><th>Max request rate:</th><td>2/s</td></tr></table></div></u></td><td>-</td><td>1</td><td>4</td><td>10</td><td><u>18<div class=tips><table class=det><tr><th>Cum. connections:</th><td>18</td></tr><tr><th>Cum. sessions:</th><td>18</td></tr><tr><th>Cum. HTTP requests:</th><td>18</td></tr><tr><th>- HTTP 1xx responses:</th><td>0</td></tr><tr><th>- HTTP 2xx responses:</th><td>5</td></tr><tr><th>&nbsp;&nbsp;Compressed 2xx:</th><td>0</td><td>(0%)</td></tr><tr><th>- HTTP 3xx responses:</th><td>0</td></tr><tr><th>- HTTP 4xx responses:</th><td>5</td></tr><tr><th>- HTTP 5xx responses:</th><td>7</td></tr><tr><th>- other responses:</th><td>0</td></tr><tr><th>Intercepted requests:</th><td>6</td></tr></table></div></u></td><td></td><td></td><td><span class="rls">5</span>802</td><td>7<span class="rls">9</span>621<div class=tips>compression: in=0 out=0 bypassed=0 savings=0%</div></td><td>0</td><td>0</td><td>5</td><td></td><td></td><td></td><td></td><td class=ac>OPEN</td><td class=ac colspan=8></td></tr><tr class="backend"><td class=ac><a name="stats/Backend"></a><a class=lfsb href="#stats/Backend">Backend</a></td><td>0</td><td>0</td><td></td><td>0</td><td>2</td><td></td><td>0</td><td>1</td><td>1</td><td><u>7<div class=tips><table class=det><tr><th>Cum. sessions:</th><td>7</td></tr><tr><th>Cum. HTTP requests:</th><td>7</td></tr><tr><th>- HTTP 1xx responses:</th><td>0</td></tr><tr><th>- HTTP 2xx responses:</th><td>0</td></tr><tr><th>&nbsp;&nbsp;Compressed 2xx:</th><td>0</td><td>(0%)</td></tr><tr><th>- HTTP 3xx responses:</th><td>0</td></tr><tr><th>- HTTP 4xx responses:</th><td>0</td></tr><tr><th>- HTTP 5xx responses:</th><td>7</td></tr><tr><th>- other responses:</th><td>0</td></tr><tr><th>Intercepted requests:</th><td>0</td></tr><tr><th colspan=3>Avg over last 1024 success. conn.</th></tr><tr><th>- Queue time:</th><td>0</td><td>ms</td></tr><tr><th>- Connect time:</th><td>0</td><td>ms</td></tr><tr><th>- Response time:</th><td>1</td><td>ms</td></tr><tr><th>- Total time:</th><td>18</td><td>ms</td></tr></table></div></u></td><td>0</td><td>0s</td><td><span class="rls">5</span>802</td><td>7<span class="rls">9</span>621<div class=tips>compression: in=0 out=0 bypassed=0 savings=0%</div></td><td>0</td><td>0</td><td></td><td>7</td><td><u>0<div class=tips>Connection resets during transfers: 0 client, 0 server</div></u></td><td>0</td><td>0</td><td class=ac>6h24m UP</td><td class=ac>&nbsp;</td><td class=ac>0</td><td class=ac>0</td><td class=ac>0</td><td class=ac>&nbsp;</td><td>0</td><td>&nbsp;</td><td></td></tr></table><p>

请帮忙...因为html标签是相同的我不知道怎样才能获得提取值。谢谢大家。

         Denied    Errors         Warnings    Server 
         Req Resp  Req Conn Resp  Retr Redis  LastChk
frontend  0   0     0    0    0    0    0     L4OK in 0ms  

html文件的内容在https://pastebin.com/41594ADP

0 个答案:

没有答案