title: Python - AttributeError: 'NoneType' object has no attribute 'get_text'
body: <p>I am following some tutorial for bs4. I am trying to get_text() for below example with 'a'. Tutorial return result McDermott International and MDR without problem. But when I do I got AttributeError: 'NoneType' object has no attribute 'get_text'. Please help. Many thanks!</p>
  
  <pre><code>with open('Energy.htm') as f:
      soup = BeautifulSoup(f,"lxml")
  energylist = soup.find_all('td', {"style" : "text-align:left;"})
  for stock in energylist:
      try:
          stock_name = stock.find('a').get_text()
      except:
          stock_name = ''
  
  #sample of the energylist
  [&lt;td style="text-align:left;"&gt;
  &lt;a href="/finance?q=NYSE:MDR&amp;amp;ei=nblKWaDrOs7AmgH0l7S4Bg"&gt;McDermott 
  International&lt;/a&gt;
  &lt;/td&gt;, &lt;td style="text-align:left;"&gt;
  &lt;a href="/finance?q=NYSE:MDR&amp;amp;ei=nblKWaDrOs7AmgH0l7S4Bg"&gt;MDR&lt;/a&gt;
  &lt;/td&gt;, &lt;td style="text-align:left;"&gt;
  &lt;a href="/finance?q=NYSE:EQT&amp;amp;ei=nblKWaDrOs7AmgH0l7S4Bg"&gt;EQT&lt;/a&gt;
  &lt;/td&gt;, &lt;td colspan="8" style="text-align:left;"&gt;
  Companies &lt;b&gt;1 - 20&lt;/b&gt; of about &lt;b&gt;476&lt;/b&gt; in &lt;b&gt;Energy&lt;/b&gt; 
  &lt;/td&gt;]
  </code></pre>