Filter search results by checking category titles and dates

def _filter_results(self, result, anchor):
        """Filter search results by checking category titles and dates"""
        valid = True

        try:
            cat_tag = result.find('a', {'rel': 'category tag'}).string
            title = anchor.string.lower()
            date_tag = result.find('time').string
        except (AttributeError, TypeError):
            return False      
             
        if cat_tag != "Daily Ratings":
            valid = False
        if not date_in_range(self.date, date_tag, 5):
            valid = False
        if self.category == 'cable' and 'cable' not in title:
            valid = False
        elif self.category != 'cable' and 'cable' in title:
            valid = False

        return valid