Beautiful Soup: extracting tagged and untagged HTML text
<p>As a novice with bs4 I'm looking for some help in working out how to extract the text from a series of webpage tables, one of which is like this:</p>

<pre><code>&lt;table style="padding:0px; margin:1px" width="715px"&gt;
&lt;tr&gt;
&lt;td height="22" width="33%" &gt;
&lt;span class="darkGreenText"&gt;&lt;strong&gt; Name: &lt;/strong&gt;&lt;/span&gt;
Tyto alba
&lt;/td&gt;
&lt;td height="22" width="33%" &gt;
&lt;span class="darkGreenText"&gt;&lt;strong&gt; Order: &lt;/strong&gt;&lt;/span&gt;
Strigiformes
&lt;/td&gt;
&lt;td height="22" width="33%"&gt;
&lt;span class="darkGreenText"&gt;&lt;strong&gt; Family: &lt;/strong&gt;&lt;/span&gt;
Tytonidae
&lt;/td&gt;
&lt;td height="22" width="66%" colspan="2"&gt;
&lt;span class="darkGreenText"&gt;&lt;strong&gt; Status: &lt;/strong&gt;&lt;/span&gt;
Least Concern
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>Desired output:</p>

<pre><code>Name: Tyto alba
Order: Strigiformes
Family: Tytonidae
Status: Least Concern
</code></pre>

<p>I've tried using <code>[index]</code>  as recommended (<a href="http://stackoverflow.com/a/35050622/1726290">http://stackoverflow.com/a/35050622/1726290</a>), 
and also <code>next_sibling</code> (<a href="http://stackoverflow.com/a/23380225/1726290">http://stackoverflow.com/a/23380225/1726290</a>) but I'm getting stuck as one part of the text I need is tagged and the second part is not. Any help would be appreciated.</p>

<p>It seems like what you want is to call <code>get_text(strip=True)</code>(<a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#get-text" rel="nofollow">docs</a>) on the BeautifulSoup Tag. Assuming <code>raw_html</code> is the html you pasted above:</p>

<p><code>htmlSoup = BeautifulSoup(raw_html)
for tag in htmlSoup.select('td'):
    print(tag.get_text(strip=True))
</code></p>

<p>which prints:</p>

<p><code>Name:Tyto alba
Order:Strigiformes
Family:Tytonidae
Status:Least Concern</code></p>

python beautifulsoup