Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
bs4.element.Tag Class Reference
Inheritance diagram for bs4.element.Tag:
Inheritance graph
[legend]
Collaboration diagram for bs4.element.Tag:
Collaboration graph
[legend]

Classes

class  _TreeTraversalEvent
 

Public Member Functions

 __init__ (self, Optional[BeautifulSoup] parser=None, Optional[TreeBuilder] builder=None, Optional[str] name=None, Optional[str] namespace=None, Optional[str] prefix=None, Optional[_RawOrProcessedAttributeValues] attrs=None, Optional[Union[BeautifulSoup, Tag]] parent=None, _AtMostOneElement previous=None, Optional[bool] is_xml=None, Optional[int] sourceline=None, Optional[int] sourcepos=None, Optional[bool] can_be_empty_element=None, Optional[Dict[str, Set[str]]] cdata_list_attributes=None, Optional[Set[str]] preserve_whitespace_tags=None, Optional[Set[Type[NavigableString]]] interesting_string_types=None, Optional[Dict[str, str]] namespaces=None)
 
Self __deepcopy__ (self, Dict[Any, Any] memo, bool recursive=True)
 
Self copy_self (self)
 
bool is_empty_element (self)
 
bool isSelfClosing (self)
 
Optional[str] string (self)
 
None string (self, str string)
 
List[PageElementinsert (self, int position, *_InsertableElement new_children)
 
Self unwrap (self)
 
_OneElement replaceWithChildren (self)
 
PageElement append (self, _InsertableElement tag)
 
List[PageElementextend (self, Union[Iterable[_InsertableElement], Tag] tags)
 
None clear (self, bool decompose=False)
 
None smooth (self)
 
int index (self, PageElement element)
 
Optional[_AttributeValue] get (self, str key, Optional[_AttributeValue] default=None)
 
AttributeValueList get_attribute_list (self, str key, Optional[AttributeValueList] default=None)
 
bool has_attr (self, str key)
 
int __hash__ (self)
 
_AttributeValue __getitem__ (self, str key)
 
Iterator[PageElement__iter__ (self)
 
int __len__ (self)
 
bool __contains__ (self, Any x)
 
bool __bool__ (self)
 
None __setitem__ (self, str key, _AttributeValue value)
 
None __delitem__ (self, str key)
 
_SomeTags __call__ (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, bool recursive=True, None string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_SomeNavigableStrings __call__ (self, None name=None, None attrs=None, bool recursive=True, _StrainableString string="", Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Union[_SomeTags, _SomeNavigableStrings, _QueryResults] __call__ (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, bool recursive=True, Optional[_StrainableString] string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Optional[Tag__getattr__ (self, str subtag)
 
bool __eq__ (self, Any other)
 
bool __ne__ (self, Any other)
 
str __repr__ (self)
 
bytes encode (self, _Encoding encoding=DEFAULT_OUTPUT_ENCODING, Optional[int] indent_level=None, _FormatterOrName formatter="minimal", str errors="xmlcharrefreplace")
 
str decode (self, Optional[int] indent_level=None, _Encoding eventual_encoding=DEFAULT_OUTPUT_ENCODING, _FormatterOrName formatter="minimal", Optional[Iterator[PageElement]] iterator=None)
 
str prettify (self, None encoding=None, _FormatterOrName formatter="minimal")
 
bytes prettify (self, _Encoding encoding, _FormatterOrName formatter="minimal")
 
Union[str, bytes] prettify (self, Optional[_Encoding] encoding=None, _FormatterOrName formatter="minimal")
 
str decode_contents (self, Optional[int] indent_level=None, _Encoding eventual_encoding=DEFAULT_OUTPUT_ENCODING, _FormatterOrName formatter="minimal")
 
bytes encode_contents (self, Optional[int] indent_level=None, _Encoding encoding=DEFAULT_OUTPUT_ENCODING, _FormatterOrName formatter="minimal")
 
bytes renderContents (self, _Encoding encoding=DEFAULT_OUTPUT_ENCODING, bool prettyPrint=False, Optional[int] indentLevel=0)
 
_AtMostOneTag find (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, bool recursive=True, None string=None, **_StrainableAttribute kwargs)
 
_AtMostOneNavigableString find (self, None name=None, None attrs=None, bool recursive=True, _StrainableString string="")
 
Union[_AtMostOneTag, _AtMostOneNavigableString, _AtMostOneElement] find (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, bool recursive=True, Optional[_StrainableString] string=None, **_StrainableAttribute kwargs)
 
_SomeTags find_all (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, bool recursive=True, None string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_SomeNavigableStrings find_all (self, None name=None, None attrs=None, bool recursive=True, _StrainableString string="", Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Union[_SomeTags, _SomeNavigableStrings, _QueryResults] find_all (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, bool recursive=True, Optional[_StrainableString] string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Iterator[PageElementchildren (self)
 
Iterator[PageElementself_and_descendants (self)
 
Iterator[PageElementdescendants (self)
 
Optional[Tagselect_one (self, str selector, Optional[Dict[str, str]] namespaces=None, **Any kwargs)
 
ResultSet[Tagselect (self, str selector, Optional[Dict[str, str]] namespaces=None, int limit=0, **Any kwargs)
 
CSS css (self)
 
Iterator[PageElementchildGenerator (self)
 
Iterator[PageElementrecursiveChildGenerator (self)
 
bool has_key (self, str key)
 
- Public Member Functions inherited from bs4.element.PageElement
None setup (self, Optional[Tag] parent=None, _AtMostOneElement previous_element=None, _AtMostOneElement next_element=None, _AtMostOneElement previous_sibling=None, _AtMostOneElement next_sibling=None)
 
str format_string (self, str s, Optional[_FormatterOrName] formatter)
 
Formatter formatter_for_name (self, Union[_FormatterOrName, _EntitySubstitutionFunction] formatter_name)
 
Self __copy__ (self)
 
Iterator[str] stripped_strings (self)
 
str get_text (self, str separator="", bool strip=False, Iterable[Type[NavigableString]] types=default)
 
Self replace_with (self, *_InsertableElement args)
 
Tag wrap (self, Tag wrap_inside)
 
Self extract (self, Optional[int] _self_index=None)
 
None decompose (self)
 
List[PageElementinsert_before (self, *_InsertableElement args)
 
List[PageElementinsert_after (self, *_InsertableElement args)
 
_AtMostOneTag find_next (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, **_StrainableAttribute kwargs)
 
_AtMostOneNavigableString find_next (self, None name=None, None attrs=None, _StrainableString string="", **_StrainableAttribute kwargs)
 
Union[_AtMostOneTag, _AtMostOneNavigableString, _AtMostOneElement] find_next (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, **_StrainableAttribute kwargs)
 
_SomeTags find_all_next (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_SomeNavigableStrings find_all_next (self, None name=None, None attrs=None, _StrainableString string="", Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Union[_SomeTags, _SomeNavigableStrings, _QueryResults] find_all_next (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_AtMostOneTag find_next_sibling (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, **_StrainableAttribute kwargs)
 
_AtMostOneNavigableString find_next_sibling (self, None name=None, None attrs=None, _StrainableString string="", **_StrainableAttribute kwargs)
 
Union[_AtMostOneTag, _AtMostOneNavigableString, _AtMostOneElement] find_next_sibling (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, **_StrainableAttribute kwargs)
 
_SomeTags find_next_siblings (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_SomeNavigableStrings find_next_siblings (self, None name=None, None attrs=None, _StrainableString string="", Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Union[_SomeTags, _SomeNavigableStrings, _QueryResults] find_next_siblings (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_AtMostOneTag find_previous (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, **_StrainableAttribute kwargs)
 
_AtMostOneNavigableString find_previous (self, None name=None, None attrs=None, _StrainableString string="", **_StrainableAttribute kwargs)
 
Union[_AtMostOneTag, _AtMostOneNavigableString, _AtMostOneElement] find_previous (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, **_StrainableAttribute kwargs)
 
_SomeTags find_all_previous (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_SomeNavigableStrings find_all_previous (self, None name=None, None attrs=None, _StrainableString string="", Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Union[_SomeTags, _SomeNavigableStrings, _QueryResults] find_all_previous (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_AtMostOneTag find_previous_sibling (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, **_StrainableAttribute kwargs)
 
_AtMostOneNavigableString find_previous_sibling (self, None name=None, None attrs=None, _StrainableString string="", **_StrainableAttribute kwargs)
 
Union[_AtMostOneTag, _AtMostOneNavigableString, _AtMostOneElement] find_previous_sibling (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, **_StrainableAttribute kwargs)
 
_SomeTags find_previous_siblings (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, None string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_SomeNavigableStrings find_previous_siblings (self, None name=None, None attrs=None, _StrainableString string="", Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
Union[_SomeTags, _SomeNavigableStrings, _QueryResults] find_previous_siblings (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[_StrainableString] string=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_AtMostOneTag find_parent (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, **_StrainableAttribute kwargs)
 
_SomeTags find_parents (self, _FindMethodName name=None, Optional[_StrainableAttributes] attrs=None, Optional[int] limit=None, int _stacklevel=2, **_StrainableAttribute kwargs)
 
_AtMostOneElement next (self)
 
_AtMostOneElement previous (self)
 
Iterator[PageElementnext_elements (self)
 
Iterator[PageElementself_and_next_elements (self)
 
Iterator[PageElementnext_siblings (self)
 
Iterator[PageElementself_and_next_siblings (self)
 
Iterator[PageElementprevious_elements (self)
 
Iterator[PageElementself_and_previous_elements (self)
 
Iterator[PageElementprevious_siblings (self)
 
Iterator[PageElementself_and_previous_siblings (self)
 
Iterator[Tagparents (self)
 
Iterator[PageElementself_and_parents (self)
 
bool decomposed (self)
 
Iterator[PageElementnextGenerator (self)
 
Iterator[PageElementnextSiblingGenerator (self)
 
Iterator[PageElementpreviousGenerator (self)
 
Iterator[PageElementpreviousSiblingGenerator (self)
 
Iterator[PageElementparentGenerator (self)
 

Public Attributes

 parser_class
 
 name
 
 namespace
 
 prefix
 
 sourceline
 
 sourcepos
 
 attribute_value_list_class
 
 attrs
 
 known_xml
 
 hidden
 
 can_be_empty_element
 
 cdata_list_attributes
 
 preserve_whitespace_tags
 
 interesting_string_types
 
 descendants
 
 contents
 
- Public Attributes inherited from bs4.element.PageElement
 parent
 
 previous_element
 
 next_element
 
 next_sibling
 
 previous_sibling
 
 find_all_next
 
 next_elements
 
 find_next_siblings
 
 next_siblings
 
 find_all_previous
 
 previous_elements
 
 find_previous_siblings
 
 previous_siblings
 
 parents
 

Static Public Attributes

Optional parser_class [type[BeautifulSoup]]
 
str name
 
Optional namespace [str]
 
Optional prefix [str]
 
_AttributeValues attrs
 
Optional sourceline [int]
 
Optional sourcepos [int]
 
Optional known_xml [bool]
 
List contents [PageElement]
 
bool hidden
 
Optional interesting_string_types [Set[Type[NavigableString]]]
 
Optional can_be_empty_element [bool]
 
Optional cdata_list_attributes [Dict[str, Set[str]]]
 
Optional preserve_whitespace_tags [Set[str]]
 
 parserClass = _deprecated_alias("parserClass", "parser_class", "4.0.0")
 
dict MAIN_CONTENT_STRING_TYPES = {NavigableString, CData}
 
Self replace_with_children = unwrap
 
 START_ELEMENT_EVENT = _TreeTraversalEvent()
 
 END_ELEMENT_EVENT = _TreeTraversalEvent()
 
 EMPTY_ELEMENT_EVENT = _TreeTraversalEvent()
 
 STRING_ELEMENT_EVENT = _TreeTraversalEvent()
 
 findChild = _deprecated_function_alias("findChild", "find", "3.0.0")
 
 findAll = _deprecated_function_alias("findAll", "find_all", "4.0.0")
 
 findChildren = _deprecated_function_alias("findChildren", "find_all", "3.0.0")
 
- Static Public Attributes inherited from bs4.element.PageElement
Optional known_xml = None
 
Optional parent [Tag]
 
_AtMostOneElement next_element
 
_AtMostOneElement previous_element
 
_AtMostOneElement next_sibling
 
_AtMostOneElement previous_sibling
 
bool hidden = False
 
 nextSibling = _deprecated_alias("nextSibling", "next_sibling", "4.0.0")
 
 previousSibling = _deprecated_alias("previousSibling", "previous_sibling", "4.0.0")
 
Iterable default = tuple()
 
str getText = get_text
 
 replaceWith = _deprecated_function_alias("replaceWith", "replace_with", "4.0.0")
 
 findNext = _deprecated_function_alias("findNext", "find_next", "4.0.0")
 
 findAllNext = _deprecated_function_alias("findAllNext", "find_all_next", "4.0.0")
 
 findNextSibling
 
 findNextSiblings
 
 fetchNextSiblings
 
 findPrevious = _deprecated_function_alias("findPrevious", "find_previous", "3.0.0")
 
 findAllPrevious
 
 fetchAllPrevious
 
 findPreviousSibling
 
 findPreviousSiblings
 
 fetchPreviousSiblings
 
 findParent = _deprecated_function_alias("findParent", "find_parent", "4.0.0")
 
 findParents = _deprecated_function_alias("findParents", "find_parents", "4.0.0")
 
 fetchParents = _deprecated_function_alias("fetchParents", "find_parents", "3.0.0")
 

Protected Member Functions

Iterator[str] _all_strings (self, bool strip=False, _OneOrMoreStringTypes types=PageElement.default)
 
List[PageElement_insert (self, int position, _InsertableElement new_child)
 
Iterator[Tuple[_TreeTraversalEvent, PageElement]] _event_stream (self, Optional[Iterator[PageElement]] iterator=None)
 
str _indent_string (self, str s, int indent_level, Formatter formatter, bool indent_before, bool indent_after)
 
str _format_tag (self, str eventual_encoding, Formatter formatter, bool opening)
 
bool _should_pretty_print (self, int indent_level=1)
 
- Protected Member Functions inherited from bs4.element.PageElement
bool _is_xml (self)
 
_AtMostOneElement _last_descendant (self, bool is_initialized=True, bool accept_self=True)
 
_AtMostOneElement _find_one (self, Callable method, _FindMethodName name, Optional[_StrainableAttributes] attrs, Optional[_StrainableString] string, **_StrainableAttribute kwargs)
 
_QueryResults _find_all (self, _FindMethodName name, Optional[_StrainableAttributes] attrs, Optional[_StrainableString] string, Optional[int] limit, Iterator[PageElement] generator, int _stacklevel=3, **_StrainableAttribute kwargs)
 
Iterator[PageElement_self_and (self, Iterator[PageElement] other_generator)
 

Protected Attributes

 _namespaces
 

Properties

 strings = property(_all_strings)
 
- Properties inherited from bs4.element.PageElement
 text = property(get_text)
 

Additional Inherited Members

- Static Protected Attributes inherited from bs4.element.PageElement
bool _decomposed
 
 _lastRecursiveChild
 

Detailed Description

An HTML or XML tag that is part of a parse tree, along with its
attributes, contents, and relationships to other parts of the tree.

When Beautiful Soup parses the markup ``<b>penguin</b>``, it will
create a `Tag` object representing the ``<b>`` tag. You can
instantiate `Tag` objects directly, but it's not necessary unless
you're adding entirely new markup to a parsed document. Most of
the constructor arguments are intended for use by the `TreeBuilder`
that's parsing a document.

:param parser: A `BeautifulSoup` object representing the parse tree this
    `Tag` will be part of.
:param builder: The `TreeBuilder` being used to build the tree.
:param name: The name of the tag.
:param namespace: The URI of this tag's XML namespace, if any.
:param prefix: The prefix for this tag's XML namespace, if any.
:param attrs: A dictionary of attribute values.
:param parent: The `Tag` to use as the parent of this `Tag`. May be
   the `BeautifulSoup` object itself.
:param previous: The `PageElement` that was parsed immediately before
    parsing this tag.
:param is_xml: If True, this is an XML tag. Otherwise, this is an
    HTML tag.
:param sourceline: The line number where this tag was found in its
    source document.
:param sourcepos: The character position within ``sourceline`` where this
    tag was found.
:param can_be_empty_element: If True, this tag should be
    represented as <tag/>. If False, this tag should be represented
    as <tag></tag>.
:param cdata_list_attributes: A dictionary of attributes whose values should
    be parsed as lists of strings if they ever show up on this tag.
:param preserve_whitespace_tags: Names of tags whose contents
    should have their whitespace preserved if they are encountered inside
    this tag.
:param interesting_string_types: When iterating over this tag's
    string contents in methods like `Tag.strings` or
    `PageElement.get_text`, these are the types of strings that are
    interesting enough to be considered. By default,
    `NavigableString` (normal strings) and `CData` (CDATA
    sections) are the only interesting string subtypes.
:param namespaces: A dictionary mapping currently active
    namespace prefixes to URIs, as of the point in the parsing process when
    this tag was encountered. This can be used later to
    construct CSS selectors.

Constructor & Destructor Documentation

◆ __init__()

bs4.element.Tag.__init__ (   self,
Optional[BeautifulSoup]   parser = None,
Optional[TreeBuilder]   builder = None,
Optional[str]   name = None,
Optional[str]   namespace = None,
Optional[str]   prefix = None,
Optional[_RawOrProcessedAttributeValues]   attrs = None,
Optional[Union[BeautifulSoup, Tag]]   parent = None,
_AtMostOneElement   previous = None,
Optional[bool]   is_xml = None,
Optional[int]   sourceline = None,
Optional[int]   sourcepos = None,
Optional[bool]   can_be_empty_element = None,
Optional[Dict[str, Set[str]]]   cdata_list_attributes = None,
Optional[Set[str]]   preserve_whitespace_tags = None,
Optional[Set[Type[NavigableString]]]   interesting_string_types = None,
Optional[Dict[str, str]]   namespaces = None 
)

Reimplemented in bs4.BeautifulStoneSoup, and bs4.BeautifulSoup.

Member Function Documentation

◆ __call__()

Union[_SomeTags,_SomeNavigableStrings,_QueryResults] bs4.element.Tag.__call__ (   self,
_FindMethodName   name = None,
Optional[_StrainableAttributes]   attrs = None,
bool   recursive = True,
Optional[_StrainableString]   string = None,
Optional[int]   limit = None,
int   _stacklevel = 2,
**_StrainableAttribute  kwargs 
)
Calling a Tag like a function is the same as calling its
find_all() method. Eg. tag('a') returns a list of all the A tags
found within this tag.

◆ __deepcopy__()

Self bs4.element.Tag.__deepcopy__ (   self,
Dict[Any, Any]  memo,
bool   recursive = True 
)
A deepcopy of a Tag is a new Tag, unconnected to the parse tree.
Its contents are a copy of the old Tag's contents.

Reimplemented from bs4.element.PageElement.

◆ __eq__()

bool bs4.element.Tag.__eq__ (   self,
Any  other 
)
Returns true iff this Tag has the same name, the same attributes,
and the same contents (recursively) as `other`.

◆ __getattr__()

Optional[Tag] bs4.element.Tag.__getattr__ (   self,
str  subtag 
)
Calling tag.subtag is the same as calling tag.find(name="subtag")

◆ __getitem__()

_AttributeValue bs4.element.Tag.__getitem__ (   self,
str  key 
)
tag[key] returns the value of the 'key' attribute for the Tag,
and throws an exception if it's not there.

◆ __ne__()

bool bs4.element.Tag.__ne__ (   self,
Any  other 
)
Returns true iff this Tag is not identical to `other`,
as defined in __eq__.

◆ __repr__()

str bs4.element.Tag.__repr__ (   self)
Renders this `Tag` as a string.

◆ __setitem__()

None bs4.element.Tag.__setitem__ (   self,
str  key,
_AttributeValue  value 
)
Setting tag[key] sets the value of the 'key' attribute for the
tag.

◆ _all_strings()

Iterator[str] bs4.element.Tag._all_strings (   self,
bool   strip = False,
_OneOrMoreStringTypes   types = PageElement.default 
)
protected
Yield all strings of certain classes, possibly stripping them.

:param strip: If True, all strings will be stripped before being
    yielded.

:param types: A tuple of NavigableString subclasses. Any strings of
    a subclass not found in this list will be ignored. By
    default, the subclasses considered are the ones found in
    self.interesting_string_types. If that's not specified,
    only NavigableString and CData objects will be
    considered. That means no comments, processing
    instructions, etc.

Reimplemented from bs4.element.PageElement.

◆ _event_stream()

Iterator[Tuple[_TreeTraversalEvent, PageElement]] bs4.element.Tag._event_stream (   self,
Optional[Iterator[PageElement]]   iterator = None 
)
protected
Yield a sequence of events that can be used to reconstruct the DOM
for this element.

This lets us recreate the nested structure of this element
(e.g. when formatting it as a string) without using recursive
method calls.

This is similar in concept to the SAX API, but it's a simpler
interface designed for internal use. The events are different
from SAX and the arguments associated with the events are Tags
and other Beautiful Soup objects.

:param iterator: An alternate iterator to use when traversing
 the tree.

◆ _indent_string()

str bs4.element.Tag._indent_string (   self,
str  s,
int  indent_level,
Formatter  formatter,
bool  indent_before,
bool  indent_after 
)
protected
Add indentation whitespace before and/or after a string.

:param s: The string to amend with whitespace.
:param indent_level: The indentation level; affects how much
   whitespace goes before the string.
:param indent_before: Whether or not to add whitespace
   before the string.
:param indent_after: Whether or not to add whitespace
   (a newline) after the string.

◆ _should_pretty_print()

bool bs4.element.Tag._should_pretty_print (   self,
int   indent_level = 1 
)
protected
Should this tag be pretty-printed?

Most of them should, but some (such as <pre> in HTML
documents) should not.

◆ append()

PageElement bs4.element.Tag.append (   self,
_InsertableElement  tag 
)
Appends the given `PageElement` to the contents of this `Tag`.

:param tag: A PageElement.

:return The newly appended PageElement.

◆ childGenerator()

Iterator[PageElement] bs4.element.Tag.childGenerator (   self)
Deprecated generator.

:meta private:

◆ children()

Iterator[PageElement] bs4.element.Tag.children (   self)
Iterate over all direct children of this `PageElement`.

◆ clear()

None bs4.element.Tag.clear (   self,
bool   decompose = False 
)
Destroy all children of this `Tag` by calling
   `PageElement.extract` on them.

:param decompose: If this is True, `PageElement.decompose` (a
    more destructive method) will be called instead of
    `PageElement.extract`.

◆ copy_self()

Self bs4.element.Tag.copy_self (   self)
Create a new Tag just like this one, but with no
contents and unattached to any parse tree.

This is the first step in the deepcopy process, but you can
call it on its own to create a copy of a Tag without copying its
contents.

Reimplemented in bs4.BeautifulSoup.

◆ css()

CSS bs4.element.Tag.css (   self)
Return an interface to the CSS selector API.

◆ decode()

str bs4.element.Tag.decode (   self,
Optional[int]   indent_level = None,
_Encoding   eventual_encoding = DEFAULT_OUTPUT_ENCODING,
_FormatterOrName   formatter = "minimal",
Optional[Iterator[PageElement]]   iterator = None 
)
Render this `Tag` and its contents as a Unicode string.

:param indent_level: Each line of the rendering will be
   indented this many levels. (The ``formatter`` decides what a
   'level' means, in terms of spaces or other characters
   output.) This is used internally in recursive calls while
   pretty-printing.
:param encoding: The encoding you intend to use when
   converting the string to a bytestring. decode() is *not*
   responsible for performing that encoding. This information
   is needed so that a real encoding can be substituted in if
   the document contains an encoding declaration (e.g. in a
   <meta> tag).
:param formatter: Either a `Formatter` object, or a string
    naming one of the standard formatters.
:param iterator: The iterator to use when navigating over the
    parse tree. This is only used by `Tag.decode_contents` and
    you probably won't need to use it.

Reimplemented in bs4.BeautifulSoup.

◆ decode_contents()

str bs4.element.Tag.decode_contents (   self,
Optional[int]   indent_level = None,
_Encoding   eventual_encoding = DEFAULT_OUTPUT_ENCODING,
_FormatterOrName   formatter = "minimal" 
)
Renders the contents of this tag as a Unicode string.

:param indent_level: Each line of the rendering will be
   indented this many levels. (The formatter decides what a
   'level' means in terms of spaces or other characters
   output.) Used internally in recursive calls while
   pretty-printing.

:param eventual_encoding: The tag is destined to be
   encoded into this encoding. decode_contents() is *not*
   responsible for performing that encoding. This information
   is needed so that a real encoding can be substituted in if
   the document contains an encoding declaration (e.g. in a
   <meta> tag).

:param formatter: A `Formatter` object, or a string naming one of
    the standard Formatters.

◆ descendants()

Iterator[PageElement] bs4.element.Tag.descendants (   self)
Iterate over all children of this `Tag` in a
breadth-first sequence.

◆ encode()

bytes bs4.element.Tag.encode (   self,
_Encoding   encoding = DEFAULT_OUTPUT_ENCODING,
Optional[int]   indent_level = None,
_FormatterOrName   formatter = "minimal",
str   errors = "xmlcharrefreplace" 
)
Render this `Tag` and its contents as a bytestring.

:param encoding: The encoding to use when converting to
   a bytestring. This may also affect the text of the document,
   specifically any encoding declarations within the document.
:param indent_level: Each line of the rendering will be
   indented this many levels. (The ``formatter`` decides what a
   'level' means, in terms of spaces or other characters
   output.) This is used internally in recursive calls while
   pretty-printing.
:param formatter: Either a `Formatter` object, or a string naming one of
    the standard formatters.
:param errors: An error handling strategy such as
    'xmlcharrefreplace'. This value is passed along into
    :py:meth:`str.encode` and its value should be one of the `error
    handling constants defined by Python's codecs module
    <https://docs.python.org/3/library/codecs.html#error-handlers>`_.

◆ encode_contents()

bytes bs4.element.Tag.encode_contents (   self,
Optional[int]   indent_level = None,
_Encoding   encoding = DEFAULT_OUTPUT_ENCODING,
_FormatterOrName   formatter = "minimal" 
)
Renders the contents of this PageElement as a bytestring.

:param indent_level: Each line of the rendering will be
   indented this many levels. (The ``formatter`` decides what a
   'level' means, in terms of spaces or other characters
   output.) This is used internally in recursive calls while
   pretty-printing.
:param formatter: Either a `Formatter` object, or a string naming one of
    the standard formatters.
:param encoding: The bytestring will be in this encoding.

◆ extend()

List[PageElement] bs4.element.Tag.extend (   self,
Union[Iterable[_InsertableElement], Tag tags 
)
Appends one or more objects to the contents of this
`Tag`.

:param tags: If a list of `PageElement` objects is provided,
    they will be appended to this tag's contents, one at a time.
    If a single `Tag` is provided, its `Tag.contents` will be
    used to extend this object's `Tag.contents`.

:return The list of PageElements that were appended.

◆ find()

Union[_AtMostOneTag,_AtMostOneNavigableString,_AtMostOneElement] bs4.element.Tag.find (   self,
_FindMethodName   name = None,
Optional[_StrainableAttributes]   attrs = None,
bool   recursive = True,
Optional[_StrainableString]   string = None,
**_StrainableAttribute  kwargs 
)
Look in the children of this PageElement and find the first
PageElement that matches the given criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: Additional filters on attribute values.
:param recursive: If this is True, find() will perform a
    recursive search of this Tag's children. Otherwise,
    only the direct children will be considered.
:param string: A filter on the `Tag.string` attribute.
:kwargs: Additional filters on attribute values.

◆ find_all()

Union[_SomeTags,_SomeNavigableStrings,_QueryResults] bs4.element.Tag.find_all (   self,
_FindMethodName   name = None,
Optional[_StrainableAttributes]   attrs = None,
bool   recursive = True,
Optional[_StrainableString]   string = None,
Optional[int]   limit = None,
int   _stacklevel = 2,
**_StrainableAttribute  kwargs 
)
Look in the children of this `PageElement` and find all
`PageElement` objects that match the given criteria.

All find_* methods take a common set of arguments. See the online
documentation for detailed explanations.

:param name: A filter on tag name.
:param attrs: Additional filters on attribute values.
:param recursive: If this is True, find_all() will perform a
    recursive search of this PageElement's children. Otherwise,
    only the direct children will be considered.
:param limit: Stop looking after finding this many results.
:param _stacklevel: Used internally to improve warning messages.
:kwargs: Additional filters on attribute values.

◆ get()

Optional[_AttributeValue] bs4.element.Tag.get (   self,
str  key,
Optional[_AttributeValue]   default = None 
)
Returns the value of the 'key' attribute for the tag, or
the value given for 'default' if it doesn't have that
attribute.

:param key: The attribute to look for.
:param default: Use this value if the attribute is not present
    on this `Tag`.

◆ get_attribute_list()

AttributeValueList bs4.element.Tag.get_attribute_list (   self,
str  key,
Optional[AttributeValueList]   default = None 
)
The same as get(), but always returns a (possibly empty) list.

:param key: The attribute to look for.
:param default: Use this value if the attribute is not present
    on this `Tag`.
:return: A list of strings, usually empty or containing only a single
    value.

◆ has_attr()

bool bs4.element.Tag.has_attr (   self,
str  key 
)
Does this `Tag` have an attribute with the given name?

◆ has_key()

bool bs4.element.Tag.has_key (   self,
str  key 
)
Deprecated method. This was kind of misleading because has_key()
(attributes) was different from __in__ (contents).

has_key() is gone in Python 3, anyway.

:meta private:

◆ index()

int bs4.element.Tag.index (   self,
PageElement  element 
)
Find the index of a child of this `Tag` (by identity, not value).

Doing this by identity avoids issues when a `Tag` contains two
children that have string equality.

:param element: Look for this `PageElement` in this object's contents.

◆ insert()

List[PageElement] bs4.element.Tag.insert (   self,
int  position,
*_InsertableElement  new_children 
)
Insert one or more new PageElements as a child of this `Tag`.

This works similarly to :py:meth:`list.insert`, except you can insert
multiple elements at once.

:param position: The numeric position that should be occupied
   in this Tag's `Tag.children` by the first new `PageElement`.

:param new_children: The PageElements to insert.

:return The newly inserted PageElements.

◆ is_empty_element()

bool bs4.element.Tag.is_empty_element (   self)
Is this tag an empty-element tag? (aka a self-closing tag)

A tag that has contents is never an empty-element tag.

A tag that has no contents may or may not be an empty-element
tag. It depends on the `TreeBuilder` used to create the
tag. If the builder has a designated list of empty-element
tags, then only a tag whose name shows up in that list is
considered an empty-element tag. This is usually the case
for HTML documents.

If the builder has no designated list of empty-element, then
any tag with no contents is an empty-element tag. This is usually
the case for XML documents.

◆ prettify()

Union[str, bytes] bs4.element.Tag.prettify (   self,
Optional[_Encoding]   encoding = None,
_FormatterOrName   formatter = "minimal" 
)
Pretty-print this `Tag` as a string or bytestring.

:param encoding: The encoding of the bytestring, or None if you want Unicode.
:param formatter: A Formatter object, or a string naming one of
    the standard formatters.
:return: A string (if no ``encoding`` is provided) or a bytestring
    (otherwise).

◆ recursiveChildGenerator()

Iterator[PageElement] bs4.element.Tag.recursiveChildGenerator (   self)
Deprecated generator.

:meta private:

◆ renderContents()

bytes bs4.element.Tag.renderContents (   self,
_Encoding   encoding = DEFAULT_OUTPUT_ENCODING,
bool   prettyPrint = False,
Optional[int]   indentLevel = 0 
)
Deprecated method for BS3 compatibility.

:meta private:

◆ select()

ResultSet[Tag] bs4.element.Tag.select (   self,
str  selector,
Optional[Dict[str, str]]   namespaces = None,
int   limit = 0,
**Any  kwargs 
)
Perform a CSS selection operation on the current element.

This uses the SoupSieve library.

:param selector: A string containing a CSS selector.

:param namespaces: A dictionary mapping namespace prefixes
   used in the CSS selector to namespace URIs. By default,
   Beautiful Soup will use the prefixes it encountered while
   parsing the document.

:param limit: After finding this number of results, stop looking.

:param kwargs: Keyword arguments to be passed into SoupSieve's
   soupsieve.select() method.

◆ select_one()

Optional[Tag] bs4.element.Tag.select_one (   self,
str  selector,
Optional[Dict[str, str]]   namespaces = None,
**Any   kwargs 
)
Perform a CSS selection operation on the current element.

:param selector: A CSS selector.

:param namespaces: A dictionary mapping namespace prefixes
   used in the CSS selector to namespace URIs. By default,
   Beautiful Soup will use the prefixes it encountered while
   parsing the document.

:param kwargs: Keyword arguments to be passed into Soup Sieve's
   soupsieve.select() method.

◆ self_and_descendants()

Iterator[PageElement] bs4.element.Tag.self_and_descendants (   self)
Iterate over this `Tag` and its children in a
breadth-first sequence.

◆ smooth()

None bs4.element.Tag.smooth (   self)
Smooth out the children of this `Tag` by consolidating consecutive
strings.

If you perform a lot of operations that modify the tree,
calling this method afterwards can make pretty-printed output
look more natural.

◆ string() [1/2]

Optional[str] bs4.element.Tag.string (   self)
Convenience property to get the single string within this
`Tag`, assuming there is just one.

:return: If this `Tag` has a single child that's a
 `NavigableString`, the return value is that string. If this
 element has one child `Tag`, the return value is that child's
 `Tag.string`, recursively. If this `Tag` has no children,
 or has more than one child, the return value is ``None``.

 If this property is unexpectedly returning ``None`` for you,
 it's probably because your `Tag` has more than one thing
 inside it.

◆ string() [2/2]

None bs4.element.Tag.string (   self,
str  string 
)
Replace the `Tag.contents` of this `Tag` with a single string.

◆ unwrap()

Self bs4.element.Tag.unwrap (   self)
Replace this `PageElement` with its contents.

:return: This object, no longer part of the tree.

The documentation for this class was generated from the following file: