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 |
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 |
Undocumented |
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.
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.
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.