title: Python scrape value between static HTML tags containing static text
body: <p>This is my first post in this forum and i believe that this forum would answer my basic question here. </p>
  
  <p>My requirement here consists of two steps.</p>
  
  <ol>
  <li>In the first step, i need to extract the value "Paid Death Notice" based on the tag span and class c8 and c2 for the below html data where "DOCUMENT-TYPE:" text is static and it will always be there in my HTML.</li>
  </ol>
  
  <pre class="lang-html prettyprint-override"><code>&lt;SPAN CLASS="c8"&gt;DOCUMENT-TYPE: &lt;/SPAN&gt;&lt;SPAN CLASS="c2"&gt;Paid Death Notice&lt;/SPAN&gt;&lt;/P&gt;
  </code></pre>
  
  <p>similarly for the below html data, i need to extract "Newspaper" value based on "PUBLICATION TYPE" with span and class as c8 and c2</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;SPAN CLASS="c8"&gt;PUBLICATION-TYPE: &lt;/SPAN&gt;&lt;SPAN CLASS="c2"&gt;Newspaper&lt;/SPAN&gt;
  </code></pre>
  
  <p><strong>Solution i have tried:</strong></p>
  
  <pre><code>from bs4 import BeautifulSoup
  import re
  
  data = """&lt;SPAN CLASS="c8"&gt;DOCUMENT-TYPE: &lt;/SPAN&gt;&lt;SPAN CLASS="c2"&gt;**Paid Death Notice**&lt;/SPAN&gt;
             &lt;SPAN CLASS="c8"&gt;PUBLICATION-TYPE: &lt;/SPAN&gt;&lt;SPAN CLASS="c2"&gt;Newspaper&lt;/SPAN&gt;"""
  
  
  soup = BeautifulSoup(data,'lxml')
  doc=soup.find('span',class_='c8')
  doctext=re.compile('&lt;SPAN(.*DOCUMENT-TYPE: &lt;/SPAN&gt;&lt;SPAN.*?)&lt;/SPAN&gt;')
  print(doctext.match(doc.text))
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <pre><code>None
  </code></pre>
  
  <p>Where i should get only <strong>Paid Death Notice</strong> as result</p>
  
  <ol start="2">
  <li>Similarly there could be many HTMl tags having same DOCUMENT-TYPE: field where it differs by value only, so in this case, how will i iterate the loop based under what condition?</li>
  </ol>
  
  <pre class="lang-html prettyprint-override"><code>&lt;SPAN CLASS="c8"&gt;DOCUMENT-TYPE: &lt;/SPAN&gt;&lt;SPAN CLASS="c2"&gt;Paid Notice: Deaths THORNTON, ROBERT&lt;/SPAN&gt;
  </code></pre>
  
  <p>Pls help me to resolve the issue.</p>
  
  <p>Note: I have searched in the web and tried many ways but cannot able to find right solution and i am finally posting here with the hope that i may get right solution for my question.</p>