title: Programmatically delete everything before a HTML node?
body: <p>I am trying to create a corpus of data from a set of .html pages I have stored in a directory.</p>
  
  <p>These HTML pages have lots of info I don't need.</p>
  
  <p>This info is all stored before the line </p>
  
  <pre><code>&lt;div class="channel"&gt;
  </code></pre>
  
  <p>How can I programmatically remove all of the text before </p>
  
  <pre><code>&lt;div class="channel"&gt;
  </code></pre>
  
  <p>in every HTML file in a folder?</p>
  
  <p>Bonus question for a 50point bounty : </p>
  
  <p>How do I programmatically remove everything AFTER, for example,</p>
  
  <pre><code>&lt;div class="footer"&gt;
  </code></pre>
  
  <p>?</p>
  
  <p>So if my index.html was previously :</p>
  
  <pre><code>&lt;head&gt;
     &lt;title&gt;This is bad HTML&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt; Remove me&lt;/h1&gt;
    &lt;div class="channel"&gt;
      &lt;h1&gt; This is the good data, keep me&lt;/h1&gt;
  
      &lt;p&gt; Keep this text &lt;/p&gt;
  
    &lt;/div&gt;
    &lt;div class="footer"&gt;
      &lt;h1&gt; Remove me, I am pointless&lt;/h1&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>After my script runs, I want it to be :</p>
  
  <pre><code>  &lt;div class="channel"&gt;
      &lt;h1&gt; This is the good data, keep me&lt;/h1&gt;
  
      &lt;p&gt; Keep this text &lt;/p&gt;
  
    &lt;/div&gt;
  </code></pre>