How to extract data from html table in shell script?

前端 未结 6 1461
[愿得一人]
[愿得一人] 2020-11-30 11:42

I am trying to create a BASH script what would extract the data from HTML table. Below is the example of table from where I need to extract data:

6条回答
  •  庸人自扰
    2020-11-30 12:08

    You may use html2text command and format the columns via column, e.g.:

    $ html2text table.html | column -ts'|'
    
    Component                                      Status  Time / Error
    SAVE_DOCUMENT                                           OK            0.406 s     
    GET_DOCUMENT                                            OK            0.332 s     
    DVK_SEND                                                OK            0.001 s     
    DVK_RECEIVE                                             OK            0.001 s     
    GET_USER_INFO                                           OK            0.143 s     
    NOTIFICATIONS                                           OK            0.001 s     
    ERROR_LOG                                               OK            0.001 s     
    SUMMARY_STATUS                                          OK            0.888 s     
    

    then parse it further from there (e.g. cut, awk, ex).

    In case you'd like to sort it first, you can use ex, see the example here or here.

提交回复
热议问题