class documentation

class SoupStrainer(object): (source)

View In Hierarchy

Encapsulates a number of ways of matching a markup element (tag or string). This is primarily used to underpin the find_* methods, but you can create one yourself and pass it in as `parse_only` to the `BeautifulSoup` constructor, to parse a subset of a large document.

Method __init__ Constructor.
Method __str__ A human-readable representation of this SoupStrainer.
Method search Find all items in `markup` that match this SoupStrainer.
Method search_tag Check whether a Tag with the given name and attributes would match this SoupStrainer.
Instance Variable attrs Undocumented
Instance Variable name Undocumented
Instance Variable string Undocumented
Instance Variable text Undocumented
Method _matches Undocumented
Method _normalize_search_value Undocumented
def __init__(self, name=None, attrs={}, string=None, **kwargs): (source)

Constructor. The SoupStrainer constructor takes the same arguments passed into the find_* methods. See the online documentation for detailed explanations. :param name: A filter on tag name. :param attrs: A dictionary of filters on attribute values. :param string: A filter for a NavigableString with specific text. :kwargs: A dictionary of filters on attribute values.

def __str__(self): (source)

A human-readable representation of this SoupStrainer.

def search(self, markup): (source)

Find all items in `markup` that match this SoupStrainer. Used by the core _find_all() method, which is ultimately called by all find_* methods. :param markup: A PageElement or a list of them.

def search_tag(self, markup_name=None, markup_attrs={}): (source)

Check whether a Tag with the given name and attributes would match this SoupStrainer. Used prospectively to decide whether to even bother creating a Tag object. :param markup_name: A tag name as found in some markup. :param markup_attrs: A dictionary of attributes as found in some markup. :return: True if the prospective tag would match this SoupStrainer; False otherwise.

Undocumented

Undocumented

Undocumented

Undocumented

def _matches(self, markup, match_against, already_tried=None): (source)

Undocumented

def _normalize_search_value(self, value): (source)

Undocumented