本帖最后由 XyD3 于 2023-3-17 16:59 编辑
[Python] 纯文本查看 复制代码 string = """
HRP_M<HWFW66-OA01>display security-policy rule all
2022-11-11 19:25:19.907 +08:00
Total:1144
RULE ID RULE NAME STATE ACTION HITS
-------------------------------------------------------------------------------
1214 测试1111 enable permit 0
1199 访问测试123 enable permit 0
1187 临时专机测试 disable deny 0
1200 远程桌面 enable permit 0
1213 林开发远程桌面 enable permit 0
HRP_S<HWFW66-OA02>display nat-policy rule all
2022-11-11 19:25:41.527 +08:00
Total:4
RULE ID RULE NAME STATE ACTION HITS
-------------------------------------------------------------------------------
1 wlan_to_untrust enable src-nat 12063413
2 BG_to_wlan enable src-nat 5136278
3 WLAN_to_BG enable src-nat 0
0 default enable no-nat 2800986172
-------------------------------------------------------------------------------
"""
import re
print({
k: v
for k, v in re.findall('[\s\S]*? (\S*?)-policy[\s\S]*?Total:([0-9]+)', string)
})
|