Using AWK/Grep/Bash to extract data from HTML

后端 未结 2 1629
误落风尘
误落风尘 2021-01-22 16:02

I\'m trying to make a Bash script to extract results from an HTML page. I achieved to get the content of the page with Curl, but the next step is parsing the output, which is pr

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-22 16:10

    Just use awk:

    awk -F '<[^>]+>' '
        found { sub(/^[[:space:]]*/,";"); print title $0; found=0 }
        /
    / { title=$2 } /
    / { found=1 } ' file ITEM 1;ITEM DESCRIPTION 1 ITEM 2;ITEM DESCRIPTION 2

提交回复
热议问题