BeautifulSoup - findAll not within certain tag

beautifulsoup, python

Solution

Run a filter for tags whose .parent doesn't have that class attribute. Something like

filteredDayContainers = [tag for tag in soup.find_all('div', 
    attrs = {'class': 'dayContainer'}) 
    if "disabled" not in tag.parent['class']]

Problem

So I'm trying to find a way to find all items within a BeautifulSoup object that have a certain tag that aren't within a certain other tag. For example: ``` <td class="disabled first"> <div class="dayContainer"> <p class="day"> 29 </p> <p class="moreLink"> </p> </div> </td> ``` I want to find all iterations of `class="dayContainer"`, which is simple enough, but how do I go about finding all of those that aren't first within `class="diabled"`?

Original source