title: if class not found return none in beatifulSoup
body: <p>I'm trying to get <code>None</code> if the class is not found in web scraping. For example, in some cases <code>stage-codes.html#10_99</code> doesn't exist in HTML.</p>
  <pre><code>for st in soup.find_all(&quot;ul&quot;, {&quot;class&quot;: &quot;dropdown-menu&quot;}):
      for k in st.find_all(&quot;a&quot;, {&quot;href&quot;: &quot;/stage-codes.html#10_99&quot;},limit=1):
        a = k.find(&quot;span&quot;, class_='stage-date').getText()
        print(a)
        try:
          start_date.append(a) 
        except:
          start_date.append(None) 
  </code></pre>
  <p>The 3rd index's start_date must be None instead of data of 4th index:</p>
  <p><img src="https://i.stack.imgur.com/NLoWp.png" alt="" /></p>