Get content between a pair of HTML tags using Bash

前端 未结 6 640
野趣味
野趣味 2020-11-30 09:53

I need to get the HTML contents between a pair of given tags using a bash script. As an example, having the HTML code below:



         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 10:52

    plain text processing is not good for html/xml parsing. I hope this could give you some idea:

    kent$  xmllint --xpath "//body" f.html 
    
     text
      
    text2
    text3

提交回复
热议问题