Get content between a pair of HTML tags using Bash

前端 未结 6 635
野趣味
野趣味 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:47

    Forgetting Bash due it's limitation, you can use nokogiri as command line util, as explained here.

    Example:

    curl -s http://example.com/ | nokogiri -e 'puts $_.search('\''a'\'')'
    

提交回复
热议问题