Represents a found HTML tag with its attributes and contents.
|
|
_invert(h)
Cheap function to invert a hash. |
source code
|
|
|
|
_convertEntities(self,
match)
Used in a call to re.sub to replace HTML, XML, and numeric entities
with the appropriate Unicode characters. |
source code
|
|
|
|
__init__(self,
parser,
name,
attrs=None,
parent=None,
previous=None)
Basic constructor. |
source code
|
|
|
|
get(self,
key,
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. |
source code
|
|
|
|
|
|
|
__getitem__(self,
key)
tag[key] returns the value of the 'key' attribute for the tag, and
throws an exception if it's not there. |
source code
|
|
|
|
__iter__(self)
Iterating over a tag iterates over its contents. |
source code
|
|
|
|
__len__(self)
The length of a tag is the length of its list of contents. |
source code
|
|
|
|
|
|
|
__nonzero__(self)
A tag is non-None even if it has no contents. |
source code
|
|
|
|
__setitem__(self,
key,
value)
Setting tag[key] sets the value of the 'key' attribute for the tag. |
source code
|
|
|
|
__delitem__(self,
key)
Deleting tag[key] deletes all 'key' attributes for the tag. |
source code
|
|
|
|
__call__(self,
*args,
**kwargs)
Calling a tag like a function is the same as calling its findAll()
method. |
source code
|
|
|
|
|
|
|
__eq__(self,
other)
Returns true iff this tag has the same name, the same attributes, and
the same contents (recursively) as the given tag. |
source code
|
|
|
|
__ne__(self,
other)
Returns true iff this tag is not identical to the other tag, as
defined in __eq__. |
source code
|
|
|
|
__repr__(self,
encoding='utf-8')
Renders this tag as a string. |
source code
|
|
|
|
|
|
|
_sub_entity(self,
x)
Used with a regular expression to substitute the appropriate XML
entity for an XML special character. |
source code
|
|
|
|
__str__(self,
encoding='utf-8',
prettyPrint=False,
indentLevel=0)
Returns a string or Unicode representation of this tag and its
contents. |
source code
|
|
|
|
|
|
|
renderContents(self,
encoding='utf-8',
prettyPrint=False,
indentLevel=0)
Renders the contents of this tag as a string in the given encoding. |
source code
|
|
|
|
find(self,
name=None,
attrs={},
recursive=True,
text=None,
**kwargs)
Return only the first child of this Tag matching the given criteria. |
source code
|
|
|
|
findChild(self,
name=None,
attrs={},
recursive=True,
text=None,
**kwargs)
Return only the first child of this Tag matching the given criteria. |
source code
|
|
|
|
findAll(self,
name=None,
attrs={},
recursive=True,
text=None,
limit=None,
**kwargs)
Extracts a list of Tag objects that match the given criteria. |
source code
|
|
|
|
findChildren(self,
name=None,
attrs={},
recursive=True,
text=None,
limit=None,
**kwargs)
Extracts a list of Tag objects that match the given criteria. |
source code
|
|
|
|
first(self,
name=None,
attrs={},
recursive=True,
text=None,
**kwargs)
Return only the first child of this Tag matching the given criteria. |
source code
|
|
|
|
fetch(self,
name=None,
attrs={},
recursive=True,
text=None,
limit=None,
**kwargs)
Extracts a list of Tag objects that match the given criteria. |
source code
|
|
|
|
| fetchText(self,
text=None,
recursive=True,
limit=None) |
source code
|
|
|
|
|
|
|
_getAttrMap(self)
Initializes a map representation of this tag's attributes, if not
already initialized. |
source code
|
|
|
|
|
|
|
|
|
Inherited from PageElement:
append,
extract,
fetchNextSiblings,
fetchParents,
fetchPrevious,
fetchPreviousSiblings,
findAllNext,
findAllPrevious,
findNext,
findNextSibling,
findNextSiblings,
findParent,
findParents,
findPrevious,
findPreviousSibling,
findPreviousSiblings,
insert,
nextGenerator,
nextSiblingGenerator,
parentGenerator,
previousGenerator,
previousSiblingGenerator,
replaceWith,
setup,
substituteEncoding,
toEncoding
|