title: How to catch this exception in BeautifulSoup
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3376666/using-beautifulsoup-how-to-guard-against-elements-not-being-found">Using BeautifulSoup, how to guard against elements not being found?</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following Python error when Using BeautifulSoup to find all options in a page:</p>
  
  <pre><code>   for item in soup.find(id="start_dateid").find_all('option'):
  AttributeError: 'NoneType' object has no attribute 'find_all'
  </code></pre>
  
  <p>The problem is when the page do not have id="start_dateid", will generate an error: AttributeError: 'NoneType' object has no attribute 'find_all'</p>
  
  <p>How to prevent this error?</p>