LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do I cut out a specific piece of a html page (using sed/awk or similar)? (https://www.linuxquestions.org/questions/linux-general-1/how-do-i-cut-out-a-specific-piece-of-a-html-page-using-sed-awk-or-similar-370929/)

bomix 10-08-2005 10:10 AM

How do I cut out a specific piece of a html page (using sed/awk or similar)?
 
I need to cut a specific table out of a html page. How can I do that?
I've been looking at the sed and awk/gawk commands, but it's a little overwhelming for a first-time user of those commands...

It doesn't need to be done with either sed or awk. If you know some other command that can do this easily, please let me know!

Let me explain in more detail what I nedd to do:

Take a html page like this:
Code:

<html>
<body>
  ... some html stuff ...
  <table ...>
    <tr>
      <td>...</td>
    </tr>
  </table>
  ... more html stuff ...
</body>
</html>

How do I cut out the part from "<table ...>" to "</table>" ?

homey 10-08-2005 03:55 PM

This example might get you started....
Code:

sed '/<table.*>/,/<\/table>/d' index.html >file.txt

bomix 10-08-2005 04:30 PM

Since my original post, I have started wondering if I should do what I want do in a python script. It might turn out to be easier at the end of the day.
Thanks anyway though. Even if I end up not using your contribution anyway :)


All times are GMT -5. The time now is 12:56 PM.