Delete html tags in sed or similar

后端 未结 2 954
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 21:07

I am trying to fetch contents of table from a wepage. I jsut need the contents but not the tags . I don\'t even need \"tr\" or \"td\" just

2条回答
  •  悲哀的现实
    2020-12-05 21:28

    Original:

    Mac Terminal REGEX behaves a bit differently. I was able to do this on my Mac using the following example:

    $ curl google.com | sed 's/<[^>]*>//g'
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   219  100   219    0     0    385      0 --:--:-- --:--:-- --:--:--   385
    
    301 Moved
    301 Moved
    The document has moved
    here.
    
    $ bash --version
    GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
    Copyright (C) 2007 Free Software Foundation, Inc.
    

    Edit:

    Just for clarification sake the origional looked like:

    $ curl googl.com
    
    301 Moved
    

    301 Moved

    The document has moved here.

    Also the annoying curl header can be rid of using the -s option:

    $ curl -s google.com | sed 's/<[^>]*>//g' 
    
    301 Moved
    301 Moved
    The document has moved
    here.
    
    $
    

提交回复
热议问题