AdvancedHTMLParser.Tags
index

Copyright (c) 2015, 2016, 2017, 2018, 2019 Tim Savannah under LGPLv3. All Rights Reserved.
 
See LICENSE (https://gnu.org/licenses/lgpl-3.0.txt) for more information.
 
 
AdvancedTag and TagCollection, which represent tags and their data, and other related functions.

 
Modules
       
QueryableList
copy
re
uuid

 
Classes
       
QueryableList.Base.QueryableListBase(__builtin__.list)
FilterableTagCollection
__builtin__.list(__builtin__.object)
TagCollection
__builtin__.object
AdvancedTag

 
class AdvancedTag(__builtin__.object)
    AdvancedTag - Represents a Tag. Used with AdvancedHTMLParser to create a DOM-model
 
Keep tag names lowercase.
 
Use the getters and setters instead of attributes directly, or you may lose accounting.
 
  Methods defined here:
__copy__(self)
__copy__ - Create a copy (except uid). This tag will NOT ==.
 
   but is safe to add to the same tree as its original
__deepcopy__(self, arg)
__deepcopy__ - Create a copy (except uid) for deepcopy. This tag will NOT ==
 
   but is safe to add to the same tree as its original
__eq__(self, other)
__eq__ - Test if this and other are THE SAME TAG.
 
Note: this does NOT test if the tags have the same name, attributes, etc.
    Use isTagEqual to test if a tag has the same data (other than children)
 
So for example:
 
    tag1 = document.getElementById('something')
    tag2 = copy.copy(tag1)
 
    tag1 == tag2          # This is False
    tag1.isTagEqual(tag2) # This is True
__getattribute__(self, name)
__getitem__(self, key)
__getstate__(self)
__getstate__ - Get state for pickling
 
    @return <dict>
__hash__(self)
__init__(self, tagName, attrList=None, isSelfClosing=False, ownerDocument=None)
__init__ - Construct
 
    @param tagName - String of tag name. This will be lowercased!
    @param attrList - A list of tuples (key, value)
    @param isSelfClosing - True if self-closing tag ( <tagName attrs /> ) will be set to False if text or children are added.
    @param ownerDocument <None/AdvancedHTMLParser> - The parser (document) associated with this tag, or None for no association
__ne__(self, other)
__ne__ - Test if this and other are NOT THE SAME TAG. Note
 
Note: this does NOT test if the tags have the same name, attributes, etc.
    Use isTagEqual to test if a tag has the same data (other than children)
 
@see AdvancedTag.__eq__
@see AdvancedTag.isTagEqual
__repr__(self)
__repr__ - A reconstructable representation of this AdvancedTag.
 
    TODO: Incorporate uid somehow? Without it the tags won't be the SAME TAG, but they'll be equivilant
__setattr__(self, name, value)
__setattr__ - Called with dot-access assignment, like:  myTag.attr = "value"
 
    This method applies the special HTML/JS rules to dot-access,
      and allows setting several attributes directly, and conversion on special names
      such as myTag.className -> "class" attribute
 
    @param name <str> - The name of the attribute after the dot
 
    @param value <multiple types> - The value to assign
 
    @return - The value assigned ( may not match the passed in #value, for example the attribute
                 "style" takes a string value, but will return a special type StyleAttribute to support
                 access with javascript-like behaviour
__setstate__(self, state)
__setstate__ - Set state when loading pickle
 
    @param state <dict>
__str__(self)
__str__ - Returns the HTML representation for this tag (including children).
 
    NOTE: This changed in 7.3.1 to be equivilant to self.outerHTML (or to new getHTML method, which is the same).
 
    The old method just included the start tag, the joined direct text node children, and the end tag.
        This compacts well for debug display, but doesn't give a clear picture of what's going on.
 
    The old method is still available as AdvancedTag._old__str__
 
    To revert str(myTag) back to the hold behaviour:
 
        from AdvancedHTMLParser.Tags import AdvancedTag
 
        AdvancedTag.__str__ = AdvancedTag._old__str__
addClass(self, className)
addClass - append a class name to the end of the "class" attribute, if not present
 
    @param className <str> - The name of the class to add
append = appendBlock(self, block)
appendBlock(self, block)
append / appendBlock - Append a block to this element. A block can be a string (text node), or an AdvancedTag (tag node)
 
@param <str/AdvancedTag> - block to add
 
@return - #block
 
NOTE: To add multiple blocks, @see appendBlocks
      If you know the type, use either @see appendChild for tags or @see appendText for text
appendBlocks(self, blocks)
appendBlocks - Append blocks to this element. A block can be a string (text node), or an AdvancedTag (tag node)
 
@param blocks list<str/AdvancedTag> - A list, in order to append, of blocks to add.
 
@return - #blocks
 
NOTE: To add a single block, @see appendBlock
      If you know the type, use either @see appendChild for tags or @see appendText for text
appendChild(self, child)
appendChild - Append a child to this element.
 
@param child <AdvancedTag> - Append a child element to this element
appendInnerHTML(self, html)
appendInnerHTML - Appends nodes from arbitrary HTML as if doing element.innerHTML += 'someHTML' in javascript.
 
@param html <str> - Some HTML
 
NOTE: If associated with a document ( AdvancedHTMLParser ), the html will use the encoding associated with
        that document.
 
@return - None. A browser would return innerHTML, but that's somewhat expensive on a high-level node.
  So just call .innerHTML explicitly if you need that
appendNode = appendChild(self, child)
appendText(self, text)
appendText - append some inner text
asHTML = toHTML(self)
cloneNode(self)
cloneNode - Clone this node (tag name and attributes). Does not clone children.
 
Tags will be equal according to isTagEqual method, but will contain a different internal
unique id such tag origTag != origTag.cloneNode() , as is the case in JS DOM.
contains(self, other)
contains - Check if a provided tag appears anywhere as a direct child to this node, or is this node itself.
 
    @param other <AdvancedTag> - Tag to check
 
@return <bool> - True if #other appears anywhere beneath or is this tag, otherwise False
containsUid(self, uid)
containsUid - Check if the uid (unique internal ID) appears anywhere as a direct child to this node, or the node itself.
 
    @param uid <uuid.UUID> - uuid to check
 
@return <bool> - True if #uid is this node's uid, or is the uid of any children at any level down
filter(self, **kwargs)
filter aka filterAnd - Perform a filter operation on this node and all children (and all their children, onto the end)
 
Results must match ALL the filter criteria. for ANY, use the *Or methods
 
For special filter keys, @see #AdvancedHTMLParser.AdvancedHTMLParser.filter
 
Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
  without '--no-deps' flag.)
 
For alternative without QueryableList,
  consider #AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
 
@return TagCollection<AdvancedTag>
filterAnd = filter(self, **kwargs)
filterOr(self, **kwargs)
filterOr - Perform a filter operation on this node and all children (and their children, onto the end)
 
Results must match ANY the filter criteria. for ALL, use the *AND methods
 
For special filter keys, @see #AdvancedHTMLParser.AdvancedHTMLParser.filter
 
Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
  without '--no-deps' flag.)
 
For alternative without QueryableList,
  consider #AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
 
@return TagCollection<AdvancedTag>
getAllChildNodeUids(self)
getAllChildNodeUids - Returns all the unique internal IDs for all children, and there children,
  so on and so forth until the end.
 
  For performing "contains node" kind of logic, this is more efficent than copying the entire nodeset
 
@return set<uuid.UUID> A set of uuid objects
getAllChildNodes(self)
getAllChildNodes - Gets all the children, and their children,
   and their children, and so on, all the way to the end as a TagCollection.
 
   Use .childNodes for a regular list of direct children
 
@return TagCollection<AdvancedTag> - A TagCollection of all children (and their children recursive)
getAllNodeUids(self)
getAllNodeUids - Returns all the unique internal IDs from getAllChildNodeUids, but also includes this tag's uid
 
@return set<uuid.UUID> A set of uuid objects
getAllNodes(self)
getAllNodes - Returns this node, all children, and all their children and so on till the end
 
@return TagCollection<AdvancedTag>
getAttribute(self, attrName, defaultValue=None)
getAttribute - Gets an attribute on this tag. Be wary using this for classname, maybe use addClass/removeClass. Attribute names are all lowercase.
    @return - The attribute value, or None if none exists.
getAttributesDict(self)
getAttributesDict - Get a copy of all attributes as a dict map of name -> value
 
  ALL values are converted to string and copied, so modifications will not affect the original attributes.
    If you want types like "style" to work as before, you'll need to recreate those elements (like StyleAttribute(strValue) ).
 
  @return <dict ( str(name), str(value) )> - A dict of attrName to attrValue , all as strings and copies.
getAttributesList(self)
getAttributesList - Get a copy of all attributes as a list of tuples (name, value)
 
  ALL values are converted to string and copied, so modifications will not affect the original attributes.
    If you want types like "style" to work as before, you'll need to recreate those elements (like StyleAttribute(strValue) ).
 
  @return list< tuple< str(name), str(value) > > - A list of tuples of attrName, attrValue pairs, all converted to strings.
 
    This is suitable for passing back into AdvancedTag when creating a new tag.
getBlocksTags(self)
getBlocksTags - Returns a list of tuples referencing the blocks which are direct children of this node, and the block is an AdvancedTag.
 
    The tuples are ( block, blockIdx ) where "blockIdx" is the index of self.blocks wherein the tag resides.
 
    @return list< tuple(block, blockIdx) > - A list of tuples of child blocks which are tags and their index in the self.blocks list
getBlocksText(self)
getBlocksText - Returns a list of tuples referencing the blocks which are direct children of this node, and the block is a text node (not an AdvancedTag)
 
    The tuples are ( block, blockIdx ) where "blockIdx" is the index of self.blocks wherein the text resides.
 
    @return list< tuple(block, blockIdx) > - A list of tuples of child blocks which are not tags and their index in the self.blocks list
getChildBlocks(self)
getChildBlocks - Gets the child blocks, both text and tags.
 
@see childBlocks
getChildren(self)
getChildren - returns child nodes as a searchable TagCollection.
 
    For a plain list, use .children instead
 
    @return - TagCollection of the immediate children to this tag.
getElementById(self, _id)
getElementById - Search children of this tag for a tag containing an id
 
@param _id - String of id
 
@return - AdvancedTag or None
getElementsByAttr(self, attrName, attrValue)
getElementsByAttr - Search children of this tag for tags with an attribute name/value pair
 
@param attrName - Attribute name (lowercase)
@param attrValue - Attribute value
 
@return - TagCollection of matching elements
getElementsByClassName(self, className)
getElementsByClassName - Search children of this tag for tags containing a given class name
 
@param className <str> - One or more space-separated class names
 
@return - TagCollection of matching elements
getElementsByName(self, name)
getElementsByName - Search children of this tag for tags with a given name
 
@param name - name to search
 
@return - TagCollection of matching elements
getElementsByXPath = getElementsByXPathExpression(self, xpathExprStr)
getElementsByXPathExpression(self, xpathExprStr)
getElementsByXPathExpression - Evaluate an XPath expression string, using this node as the root
 
 
    @param xpathExprStr <str> - An XPath expression string (e.x. """//div[@name="someName"]/span[3]""" )
 
 
    @return <TagCollection> - TagCollection of all matching elements
 
 
    @see AdvancedHTMLParser.xpath.XPathExpression.evaluate for additional @throws and similar
getElementsCustomFilter(self, filterFunc)
getElementsCustomFilter - Searches children of this tag for those matching a provided user function
 
@param filterFunc <function> - A function or lambda expression that should return "True" if the passed node matches criteria.
 
@return - TagCollection of matching results
 
@see getFirstElementCustomFilter
getElementsWithAttrValues(self, attrName, attrValues)
getElementsWithAttrValues - Search children of this tag for tags with an attribute name and one of several values
 
@param attrName <lowercase str> - Attribute name (lowercase)
@param attrValues set<str> - set of acceptable attribute values
 
@return - TagCollection of matching elements
getEndTag(self)
getEndTag - returns the end tag representation as HTML string
 
@return - String of end tag
getFirstElementCustomFilter(self, filterFunc)
getFirstElementCustomFilter - Gets the first element which matches a given filter func.
 
    Scans first child, to the bottom, then next child to the bottom, etc. Does not include "self" node.
 
@param filterFunc <function> - A function or lambda expression that should return "True" if the passed node matches criteria.
 
@return <AdvancedTag/None> - First match, or None
 
@see getElementsCustomFilter
getHTML = toHTML(self)
getParentElementCustomFilter(self, filterFunc)
getParentElementCustomFilter - Runs through parent on up to document root, returning the
 
                                  first tag which filterFunc(tag) returns True.
 
    @param filterFunc <function/lambda> - A function or lambda expression that should return "True" if the passed node matches criteria.
 
    @return <AdvancedTag/None> - First match, or None
 
 
    @see getFirstElementCustomFilter for matches against children
getPeers(self)
getPeers - Get elements who share a parent with this element
 
@return - TagCollection of elements
getPeersByAttr(self, attrName, attrValue)
getPeersByAttr - Gets peers (elements on same level) which match an attribute/value combination.
 
@param attrName - Name of attribute
@param attrValue - Value that must match
 
@return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
getPeersByClassName(self, className)
getPeersByClassName - Gets peers (elements on same level) with a given class name
 
@param className - classname must contain this name
 
@return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
getPeersByName(self, name)
getPeersByName - Gets peers (elements on same level) with a given name
 
@param name - Name to match
 
@return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
getPeersCustomFilter(self, filterFunc)
getPeersCustomFilter - Get elements who share a parent with this element and also pass a custom filter check
 
    @param filterFunc <lambda/function> - Passed in an element, and returns True if it should be treated as a match, otherwise False.
 
    @return <TagCollection> - Resulting peers, or None if no parent node.
getPeersWithAttrValues(self, attrName, attrValues)
getPeersWithAttrValues - Gets peers (elements on same level) whose attribute given by #attrName
    are in the list of possible vaues #attrValues
 
@param attrName - Name of attribute
@param attrValues - List of possible values which will match
 
@return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
getStartTag(self)
getStartTag - Returns the start tag represented as HTML
 
@return - String of start tag with attributes
getStyle(self, styleName)
getStyle - Gets the value of a style paramater, part of the "style" attribute
 
@param styleName - The name of the style
 
@return - String of the value of the style. '' is no value.
getStyleDict(self)
getStyleDict - Gets a dictionary of style attribute/value pairs.
 
@return - OrderedDict of "style" attribute.
getTagName(self)
getTagName - Gets the tag name of this Tag (lowercase).
 
@return - str - name of tag
getUid(self)
getUid - Get the AdvancedHTMLParser unique id for this tag.
 
    Each tag is given a generated uuid at create time, and copies also get their own unique identifier.
 
    This can be used to determine if two tags are the same tag, beyond just having equal attribute name/value pairs and children.
 
    This is used internally to prevent duplicates, for example a TagCollection does not allow multiple tags with the same uid
 
    @return - uuid.UUID object, representing a uuid as specified by RFC 4122, version 4.
       This object is optimized for comparison. For a string representation, str() the result, or use .hex or .variant
hasAttribute(self, attrName)
hasAttribute - Checks for the existance of an attribute. Attribute names are all lowercase.
 
    @param attrName <str> - The attribute name
 
    @return <bool> - True or False if attribute exists by that name
hasChild(self, child)
hasChild - Returns if #child is a DIRECT child (tag) of this node.
 
@param child <AdvancedTag> - The tag to check
 
@return <bool> - If #child is a direct child of this node, True. Otherwise, False.
hasChildNodes(self)
hasChildNodes - Checks if this node has any children (tags).
 
@return <bool> - True if this child has any children, otherwise False.
hasClass(self, className)
hasClass - Test if this tag has a paticular class name ( class attribute )
 
@param className - A class to search
 
@return <bool> - True if provided class is present, otherwise False
insertAfter(self, child, afterChild)
insertAfter - Inserts a child after #afterChild
 
 
    @param child <AdvancedTag/str> - Child block to insert
 
    @param afterChild <AdvancedTag/str> - Child block to insert after. if None, will  be appended
 
@return - The added child. Note, if it is a text block (str), the return isl NOT be linked by reference.
insertBefore(self, child, beforeChild)
insertBefore - Inserts a child before #beforeChild
 
 
    @param child <AdvancedTag/str> - Child block to insert
 
    @param beforeChild <AdvancedTag/str> - Child block to insert before. if None, will  be appended
 
@return - The added child. Note, if it is a text block (str), the return isl NOT be linked by reference.
 
@raises ValueError - If #beforeChild is defined and is not a child of this node
isEqualNode = __eq__(self, other)
isTagEqual(self, other)
isTagEqual - Compare if a tag contains the same tag name and attributes as another tag,
 
    i.e. if everything between < and > parts of this tag are the same.
 
    Does NOT compare children, etc. Does NOT compare if these are the same exact tag in the html (use regular == operator for that)
 
    So for example:
 
        tag1 = document.getElementById('something')
        tag2 = copy.copy(tag1)
 
        tag1 == tag2          # This is False
        tag1.isTagEqual(tag2) # This is True
 
    @return bool - True if tags have the same name and attributes, otherwise False
remove(self)
remove - Will remove this node from its parent, if it has a parent (thus taking it out of the HTML tree)
 
    NOTE: If you are using an IndexedAdvancedHTMLParser, calling this will NOT update the index. You MUST call
      reindex method manually.
 
@return <bool> - While JS DOM defines no return for this function, this function will return True if a
   remove did happen, or False if no parent was set.
removeAttribute(self, attrName)
removeAttribute - Removes an attribute, by name.
 
@param attrName <str> - The attribute name
removeBlock(self, block)
removeBlock - Removes a single block (text node or AdvancedTag) which is a child of this object.
 
@param block <str/AdvancedTag> - The block (text node or AdvancedTag) to remove.
 
@return Returns the removed block if one was removed, or None if requested block is not a child of this node.
 
NOTE: If you know you are going to remove an AdvancedTag, @see removeChild
      If you know you are going to remove a text node,    @see removeText
 
If removing multiple blocks, @see removeBlocks
removeBlocks(self, blocks)
removeBlock - Removes a list of blocks (the first occurance of each) from the direct children of this node.
 
@param blocks  list<str/AdvancedTag> - List of AdvancedTags for tag nodes, else strings for text nodes
 
@return The removed blocks in each slot, or None if None removed.
 
@see removeChild
@see removeText
 
For multiple, @see removeBlocks
removeChild(self, child)
removeChild - Remove a child tag, if present.
 
    @param child <AdvancedTag> - The child to remove
 
    @return - The child [with parentNode cleared] if removed, otherwise None.
 
    NOTE: This removes a tag. If removing a text block, use #removeText function.
      If you need to remove an arbitrary block (text or AdvancedTag), @see removeBlock
 
    Removing multiple children? @see removeChildren
removeChildren(self, children)
removeChildren - Remove multiple child AdvancedTags.
 
@see removeChild
 
@return list<AdvancedTag/None> - A list of all tags removed in same order as passed.
    Item is "None" if it was not attached to this node, and thus was not removed.
removeClass(self, className)
removeClass - remove a class name if present. Returns the class name if  removed, otherwise None.
 
    @param className <str> - The name of the class to remove
 
    @return <str> - The class name removed if one was removed, otherwise None if #className wasn't present
removeNode = removeChild(self, child)
removeText(self, text)
removeText - Removes the first occurace of given text in a text node (i.e. not part of a tag)
 
@param text <str> - text to remove
 
@return text <str/None> - The text in that block (text node) after remove, or None if not found
 
NOTE: To remove a node, @see removeChild
NOTE: To remove a block (maybe a node, maybe text), @see removeBlock
NOTE: To remove ALL occuraces of text, @see removeTextAll
removeTextAll(self, text)
removeTextAll - Removes ALL occuraces of given text in a text node (i.e. not part of a tag)
 
@param text <str> - text to remove
 
@return list <str> - All text node containing #text BEFORE the text was removed.
    Empty list if no text removed
 
NOTE: To remove a node, @see removeChild
NOTE: To remove a block (maybe a node, maybe text), @see removeBlock
NOTE: To remove a single occurace of text, @see removeText
setAttribute(self, attrName, attrValue)
setAttribute - Sets an attribute. Be wary using this for classname, maybe use addClass/removeClass. Attribute names are all lowercase.
 
@param attrName <str> - The name of the attribute
 
@param attrValue <str> - The value of the attribute
 
 
@raises -
 
    KeyError if #attrName is invalid name for an attribute
setAttributes(self, attributesDict)
setAttributes - Sets  several attributes at once, using a dictionary of attrName : attrValue
 
@param  attributesDict - <str:str> - New attribute names -> values
 
@raises -
setStyle(self, styleName, styleValue)
setStyle - Sets a style param. Example: "display", "block"
 
    If you need to set many styles on an element, use setStyles instead.
    It takes a dictionary of attribute, value pairs and applies it all in one go (faster)
 
    To remove a style, set its value to empty string.
    When all styles are removed, the "style" attribute will be nullified.
 
@param styleName - The name of the style element
@param styleValue - The value of which to assign the style element
 
@return - String of current value of "style" after change is made.
setStyles(self, styleUpdatesDict)
setStyles - Sets one or more style params.
    This all happens in one shot, so it is much much faster than calling setStyle for every value.
 
    To remove a style, set its value to empty string.
    When all styles are removed, the "style" attribute will be nullified.
 
@param styleUpdatesDict - Dictionary of attribute : value styles.
 
@return - String of current value of "style" after change is made.
toHTML(self)
toHTML - Get the HTML representation of this tag and all children
 
  @return <str> - HTML with this tag as the root

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
attributes
attributesDict - Returns the internal dict mapped to attributes on this object.
 
  Modifications made here WILL affect this tag, use getAttributesDict to get a copy.
 
  This is the default provider of the "attributes" property. Can be toggled to use the DOM-matching version, see @toggleAttributesDOM
 
  @return <dict> - Internal attributes
attributesDOM
attributes - Return a NamedNodeMap of the attributes on this object.
 
  This is a horrible method and is not used in practice anywhere sane.
 
  Please use setAttribute, getAttribute, hasAttribute methods instead.
 
  @see SpecialAttributes.NamedNodeMap
 
  This is NOT the default provider of the "attributes" property. Can be toggled to use the DOM-matching version, see @toggleAttributesDOM
 
@return AttributeNodeMap
attributesDict
attributesDict - Returns the internal dict mapped to attributes on this object.
 
  Modifications made here WILL affect this tag, use getAttributesDict to get a copy.
 
  This is the default provider of the "attributes" property. Can be toggled to use the DOM-matching version, see @toggleAttributesDOM
 
  @return <dict> - Internal attributes
attributesList
attributesList - Returns a copy of internal attributes as a list. Same as getAttributesList method.
 
    @return list<tuple> - List of (key, value) tuples representing each attribute on this node
 
 
  @see getAttributesList
  @see attributesDict
childBlocks
childBlocks - Return immediate child blocks, both text and tags.
 
@return list<AdvancedTag/str> - List of blocks associated with this node
 
NOTE: This does what #childNodes does in JS DOM. Because for many years childNodes has returned
  ONLY tags on AdvancedHTMLParser, it would be a major change to match. Likely will be made in a future
  version.
childElementCount
childElementCount - Returns the number of direct children to this node
 
@return <int> - The number of direct children to this node
childNodes
childNodes - returns immediate child nodes as a TagCollection
 
@return - TagCollection of child nodes
 
NOTE: Unlike JS DOM, this returns ONLY tags, not text blocks.
       Changing this would be a fairly-major backwards-incompatible change,
       and will likely be made in a future version.
 
       For now, use @see childBlocks method to get both text AND tags
classList
classList - get a copy of the list of the class names ( the "class" attribute ) for this element
 
    @return DOMTokenList<str> - A list of the class names for this element
className
className - property, string of 'class' attribute
 
@return <str> - Class attribute, or empty string if not set
classNames
classList - get a copy of the list of the class names ( the "class" attribute ) for this element
 
    @return DOMTokenList<str> - A list of the class names for this element
firstChild
firstChild - property, Get the first child block, text or tag.
 
    @return <str/AdvancedTag/None> - The first child block, or None if no child blocks
firstElementChild
firstElementChild - property, Get the first child which is an element (AdvancedTag)
 
    @return <AdvancedTag/None> - The first element child, or None if no element child nodes
innerHTML
innerHTML - Returns an HTML string of the inner contents of this tag, including children.
 
@return - String of inner contents HTML
innerText
innerText - property, gets the text of just this node. Use #textContent for this node and all children
 
        This is an alias of the .text property
 
     @return <str> - The text of this node
lastChild
lastChild - property, Get the last child block, text or tag
 
    @return <str/AdvancedTag/None> - The last child block, or None if no child blocks
lastElementChild
lastElementChild - property, Get the last child which is an element (AdvancedTag)
 
    @return <AdvancedTag/None> - The last element child, or None if no element child nodes
nextElementSibling
nextElementSibling - Returns the next sibling that is an element.
    This is the tag node following this node in the parent's list of children
 
    @return <None/AdvancedTag> - None if there are no children (tag) in the parent after this node,
                                        Otherwise the following element (tag)
nextSibling
nextSibling - Returns the next sibling. This is the child following this node in the parent's list of children.
 
        This could be text or an element. use nextSiblingElement to ensure element
 
    @return <None/str/AdvancedTag> - None if there are no nodes (text or tag) in the parent after this node,
                                        Otherwise the following node (text or tag)
nextSiblingElement
nextElementSibling - Returns the next sibling that is an element.
    This is the tag node following this node in the parent's list of children
 
    @return <None/AdvancedTag> - None if there are no children (tag) in the parent after this node,
                                        Otherwise the following element (tag)
nodeName
nodeName - Return the name of this name (tag name)
nodeType
nodeType - Return the type of this node (1 - ELEMENT_NODE)
nodeValue
nodeValue - Return the value of this node (None)
outerHTML
outerHTML - Returns start tag, innerHTML, and end tag as HTML string
 
@return - String of start tag, innerHTML, and end tag
parentElement
parentElement - get the parent element of this node
 
    @return <AdvancedTag/None> - The parent node, or None if no parent
peers
peers - Get elements with same parent as this item
 
@return - TagCollection of elements
previousElementSibling
previousElementSibling - Returns the previous  sibling  that is an element.
 
                            This is the previous tag node in the parent's list of children
 
 
    @return <None/AdvancedTag> - None if there are no children (tag) in the parent before this node,
                                        Otherwise the previous element (tag)
previousSibling
previousSibling - Returns the previous sibling. This would be the previous node (text or tag) in the parent's list
 
    This could be text or an element. use previousSiblingElement to ensure element
 
 
    @return <None/str/AdvancedTag> - None if there are no nodes (text or tag) in the parent before this node,
                                        Otherwise the previous node (text or tag)
previousSiblingElement
previousElementSibling - Returns the previous  sibling  that is an element.
 
                            This is the previous tag node in the parent's list of children
 
 
    @return <None/AdvancedTag> - None if there are no children (tag) in the parent before this node,
                                        Otherwise the previous element (tag)
tagBlocks
tagBlocks - Property.
            Returns all the blocks which are direct children of this node, where that block is a tag (not text)
 
    NOTE: This is similar to .children , and you should probably use .children instead except within this class itself
 
    @return list<AdvancedTag> - A list of direct children which are tags.
textBlocks
textBlocks - Property.
            Returns all the blocks which are direct children of this node, where that block is a text (not a tag)
 
    @return list<AdvancedTag> - A list of direct children which are text.
textContent
textContent - property, gets the text of this node and all inner nodes.
 
    Use .innerText for just this node's text
 
  @return <str> - The text of all nodes at this level or lower

 
class FilterableTagCollection(QueryableList.Base.QueryableListBase)
    
Method resolution order:
FilterableTagCollection
QueryableList.Base.QueryableListBase
__builtin__.list
__builtin__.object

Methods defined here:
filter = filterAnd(self, **kwargs)
filterAnd(self, **kwargs)
filterOr(self, **kwargs)

Methods inherited from QueryableList.Base.QueryableListBase:
__add__(self, other)
__add__ - Append all items in #other to the tail of #self
 
    + operator
 
  Returns a copy, does not modify this item.
__and__(self, other)
__and__ - Return a QueryableList (of this type) which contains all the elements in #self that are also in #other
 
  Returns a copy
__copy__(self)
__copy__ - Make a copy of this collection
__getslice__(self, start, end)
__getslice__ - Return a "slice" (subset) of the current collection.
 
Returns a copy
__iadd__(self, other)
__iadd__ - Append all items in #other to the tail of #self
 
  += operator
 
  Modifies original
__iand__(self, other)
__ior__(self, other)
__isub__(self, other)
__isub__ - Implement subtract-equals. Removes any items from #self that are present in #other
 
Works inline and modifies #self
__ixor__(self, other)
__or__(self, other)
__or__ - Append any items found in #other which are not already present in #self
 
    Returns a copy
__repr__(self)
__repr__ - Return a code representation of this class
__sub__(self, other)
__sub__ - Implement subtract. Removes any items from #self that are present in #other
 
  Returns a copy, does not modify inline
__xor__(self, other)
__xor__ - Return a QueryableList (of this type) which contains all the elements
  that appear in either #self or #other, but not both.
 
  Returns a copy
all(self)
all - Returns all items in this collection, as the collection type (aka returns a copy of "self").
 
  This method is provided for method parity with ORMs that build a filter set with filter calls,
    and then execute with ".all" (like django or IndexedRedis).
 
  That way you can filter and call ".all()" after, and it doesn't matter if you're hitting the db
    or filtering already-fetched objects, the usage remains the same.
 
@return <self.__class__> - self
count(self)
count - Returns the number of items in this collection.
 
    This is the same as len(...), but is added to be compatible with many server-side ORMs which implement "count" as a function.
 
  @return <int> - Number of items in this collection
customFilter(self, filterFunc)
customFilter - Apply a custom filter to elements and return a QueryableList of matches
 
@param filterFunc <lambda/function< - A lambda/function that is passed an item, and
   returns True if the item matches (will be returned), otherwise False.
 
@return - A QueryableList object of the same type, with only the matching objects returned.
sort_by(self, fieldName, reverse=False)
sort_by - Return a copy of this collection, sorted by the given fieldName.
 
  The fieldName is accessed the same way as other filtering, so it supports custom properties, etc.
 
  @param fieldName <str> - The name of the field on which to sort by
 
  @param reverse <bool> Default False - If True, list will be in reverse order.
 
  @return <QueryableList> - A QueryableList of the same type with the elements sorted based on arguments.

Data descriptors inherited from QueryableList.Base.QueryableListBase:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from __builtin__.list:
__contains__(...)
x.__contains__(y) <==> y in x
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__gt__(...)
x.__gt__(y) <==> x>y
__imul__(...)
x.__imul__(y) <==> x*=y
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__sizeof__(...)
L.__sizeof__() -- size of L in memory, in bytes
append(...)
L.append(object) -- append object to end
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.
insert(...)
L.insert(index, object) -- insert object before index
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
remove(...)
L.remove(value) -- remove first occurrence of value.
Raises ValueError if the value is not present.
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__hash__ = None
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class TagCollection(__builtin__.list)
    A collection of AdvancedTags. You may use this like a normal list, or you can use the various getElements* functions within to operate on the results.
Generally, this is the return of all get* functions.
 
All the get* functions called on a TagCollection search all contained elements and their childrens. If you need to check ONLY the elements in the tag collection, and not their children,
either provide your own list comprehension to do so, or use the "filterCollection" method, which takes an arbitrary function/lambda expression and filters just the immediate tags.
 
 
Method resolution order:
TagCollection
__builtin__.list
__builtin__.object

Methods defined here:
__add__(self, others)
__iadd__(self, others)
__init__(self, values=None)
Create this object.
 
@param values - Initial values, or None for empty
__isub__(self, others)
__repr__(self)
__sub__(self, others)
all(self)
all - A plain list of these elements
 
@return - List of these elements
append(self, tag)
append - Append an item to this tag collection
 
@param tag - an AdvancedTag
contains(self, em)
contains - Check if #em occurs within any of the elements within this list, as themselves or as a child, any
   number of levels down.
 
   To check if JUST an element is contained within this list directly, use the "in" operator.
 
@param em <AdvancedTag> - Element of interest
 
@return <bool> - True if contained, otherwise False
containsUid(self, uid)
containsUid - Check if #uid is the uid (unique internal identifier) of any of the elements within this list,
  as themselves or as a child, any number of levels down.
 
 
@param uid <uuid.UUID> - uuid of interest
 
@return <bool> - True if contained, otherwise False
filter(self, **kwargs)
filter aka filterAnd - Perform a filter operation on ALL nodes in this collection (NOT including children, see #filterAnd for that)
 
Results must match ALL the filter criteria. for ANY, use the *Or methods
 
For special filter keys, @see #AdvancedHTMLParser.AdvancedHTMLParser.filter
 
Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
  without '--no-deps' flag.)
 
For alternative without QueryableList,
  consider #AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
 
 
@return TagCollection<AdvancedTag>
filterAll(self, **kwargs)
filterAll aka filterAllAnd - Perform a filter operation on ALL nodes in this collection and all their children.
 
Results must match ALL the filter criteria. for ANY, use the *Or methods
 
For just the nodes in this collection, use "filter" or "filterAnd" on a TagCollection
 
For special filter keys, @see #AdvancedHTMLParser.AdvancedHTMLParser.filter
 
Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
  without '--no-deps' flag.)
 
For alternative without QueryableList,
  consider #AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
 
@return TagCollection<AdvancedTag>
filterAllOr(self, **kwargs)
filterAllOr - Perform a filter operation on ALL nodes in this collection and all their children.
 
Results must match ANY the filter criteria. for ALL, use the *And methods
 
For just the nodes in this collection, use "filterOr" on a TagCollection
 
For special filter keys, @see #AdvancedHTMLParser.AdvancedHTMLParser.filter
 
Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
  without '--no-deps' flag.)
 
For alternative without QueryableList,
  consider #AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
 
 
@return TagCollection<AdvancedTag>
filterAnd = filter(self, **kwargs)
filterCollection(self, filterFunc)
filterCollection - Filters only the immediate objects contained within this Collection against a function, not including any children
 
@param filterFunc <function> - A function or lambda expression that returns True to have that element match
 
@return TagCollection<AdvancedTag>
filterOr(self, **kwargs)
filterOr - Perform a filter operation on the nodes in this collection (NOT including children, see #filterAllOr for that)
 
Results must match ANY the filter criteria. for ALL, use the *And methods
 
For special filter keys, @see #AdvancedHTMLParser.AdvancedHTMLParser.filter
 
Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
  without '--no-deps' flag.)
 
For alternative without QueryableList,
  consider #AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
 
 
@return TagCollection<AdvancedTag>
getAllNodeUids(self)
getAllNodeUids - Gets all the internal uids of all nodes, their children, and all their children so on..
 
  @return set<uuid.UUID>
getAllNodes(self)
getAllNodes - Gets all the nodes, and all their children for every node within this collection
getElementById(self, _id)
getElementById - Gets an element within this collection by id
 
@param _id - string of "id" attribute
 
@return - a single tag matching the id, or None if none found
getElementsByAttr(self, attr, value)
getElementsByAttr - Get elements within this collection posessing a given attribute/value pair
 
@param attr - Attribute name (lowercase)
@param value - Matching value
 
@return - TagCollection of all elements matching name/value
getElementsByClassName(self, className)
getElementsByClassName - Get elements within this collection containing a specific class name
 
@param className <str> - One or more space-separated class names
 
@return - TagCollection of unique elements within this collection tagged with a specific class name
getElementsByName(self, name)
getElementsByName - Get elements within this collection having a specific name
 
@param name - String of "name" attribute
 
@return - TagCollection of unique elements within this collection with given "name"
getElementsByTagName(self, tagName)
getElementsByTagName - Gets elements within this collection having a specific tag name
 
@param tagName - String of tag name
 
@return - TagCollection of unique elements within this collection with given tag name
getElementsByXPath = getElementsByXPathExpression(self, xpathExprStr)
getElementsByXPathExpression(self, xpathExprStr)
getElementsByXPathExpression - Evaluate an XPath expression string against the elements in this collection
 
 
    @param xpathExprStr <str> - An XPath expression string (e.x. """//div[@name="someName"]/span[3]""" )
 
 
    @return <TagCollection> - TagCollection of all matching elements
 
 
    @see AdvancedHTMLParser.xpath.XPathExpression.evaluate for additional @throws and similar
getElementsCustomFilter(self, filterFunc)
getElementsCustomFilter - Get elements within this collection that match a user-provided function.
 
@param filterFunc <function> - A function that returns True if the element matches criteria
 
@return - TagCollection of all elements that matched criteria
getElementsWithAttrValues(self, attr, values)
getElementsWithAttrValues - Get elements within this collection possessing an attribute name matching one of several values
 
@param attr <lowercase str> - Attribute name (lowerase)
@param values set<str> - Set of possible matching values
 
@return - TagCollection of all elements matching criteria
remove(self, toRemove)
remove - Remove an item from this tag collection
 
@param toRemove - an AdvancedTag

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
filterAllAnd = <built-in function filter>
filter(function or None, sequence) -> list, tuple, or string
 
Return those items of sequence for which function(item) is true.  If
function is None, return the items that are true.  If sequence is a tuple
or string, return the same type, else return a list.

Methods inherited from __builtin__.list:
__contains__(...)
x.__contains__(y) <==> y in x
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__imul__(...)
x.__imul__(y) <==> x*=y
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__sizeof__(...)
L.__sizeof__() -- size of L in memory, in bytes
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.
insert(...)
L.insert(index, object) -- insert object before index
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__hash__ = None
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
Functions
       
isTagNode(node)
isTagNode - Test if given node is a tag node (AdvancedTag)
 
@param node - Node to test
 
@return bool
isTextNode(node)
isTextNode - Test if given node is a text node (Not a tag)
 
@param node - Node to test
 
@return bool
isValidAttributeName(attrName)
isValidAttributeName - Validate that an attribute name is valid.
 
  AdvancedHTMLParser will silently drop invalid attributes,
    ValidatingHTMLParser will raise exception
 
    @param attrName <str> - The attribute name to test
 
 
    @return <bool> - True if is valid name, otherwise False
toggleAttributesDOM(isEnabled)
toggleAttributesDOM - Toggle if the old DOM tag.attributes NamedNodeMap model should be used for the .attributes method, versus
 
   a more sane direct dict implementation.
 
    The DOM version is always accessable as AdvancedTag.attributesDOM
    The dict version is always accessable as AdvancedTag.attributesDict
 
    Default for AdvancedTag.attributes is to be attributesDict implementation.
 
  @param isEnabled <bool> - If True, .attributes will be changed to use the DOM-provider. Otherwise, it will use the dict provider.
uniqueTags(tagList)
uniqueTags - Returns the unique tags in tagList.
 
    @param tagList list<AdvancedTag> : A list of tag objects.

 
Data
        __all__ = ('AdvancedTag', 'uniqueTags', 'TagCollection', 'FilterableTagCollection', 'toggleAttributesDOM', 'isTextNode', 'isTagNode', 'isValidAttributeName')