CMS 3D CMS Logo

List of all members | Public Member Functions
BeautifulSoup.BeautifulSOAP Class Reference
Inheritance diagram for BeautifulSoup.BeautifulSOAP:
BeautifulSoup.BeautifulStoneSoup BeautifulSoup.Tag BeautifulSoup.PageElement BeautifulSoup.SimplifyingSOAPParser

Public Member Functions

def popTag (self)
 
- Public Member Functions inherited from BeautifulSoup.BeautifulStoneSoup
def __getattr__ (self, methodName)
 
def __init__ (self, markup="", parseOnlyThese=None, fromEncoding=None, markupMassage=True, smartQuotesTo=XML_ENTITIES, convertEntities=None, selfClosingTags=None, isHTML=False)
 
def convert_charref (self, name)
 
def endData (self, containerClass=NavigableString)
 
def handle_charref (self, ref)
 
def handle_comment (self, text)
 
def handle_data (self, data)
 
def handle_decl (self, data)
 
def handle_entityref (self, ref)
 
def handle_pi (self, text)
 
def isSelfClosingTag (self, name)
 
def parse_declaration (self, i)
 
def pushTag (self, tag)
 
def reset (self)
 
def unknown_endtag (self, name)
 
def unknown_starttag (self, name, attrs, selfClosing=0)
 
- Public Member Functions inherited from BeautifulSoup.Tag
def __call__ (self, *args, **kwargs)
 
def __contains__ (self, x)
 
def __delitem__ (self, key)
 
def __eq__ (self, other)
 
def __getitem__ (self, key)
 
def __init__ (self, parser, name, attrs=None, parent=None, previous=None)
 
def __iter__ (self)
 
def __len__ (self)
 
def __ne__ (self, other)
 
def __nonzero__ (self)
 
def __repr__ (self, encoding=DEFAULT_OUTPUT_ENCODING)
 
def __setitem__ (self, key, value)
 
def __str__ (self, encoding=DEFAULT_OUTPUT_ENCODING, prettyPrint=False, indentLevel=0)
 
def __unicode__ (self)
 
def childGenerator (self)
 
def clear (self)
 
def decompose (self)
 
def fetchText (self, text=None, recursive=True, limit=None)
 
def find (self, name=None, attrs={}, recursive=True, text=None, **kwargs)
 
def findAll (self, name=None, attrs={}, recursive=True, text=None, limit=None, **kwargs)
 
def firstText (self, text=None, recursive=True)
 
def get (self, key, default=None)
 
def getString (self)
 
def getText (self, separator=u"")
 
def has_key (self, key)
 
def index (self, element)
 
def prettify (self, encoding=DEFAULT_OUTPUT_ENCODING)
 
def recursiveChildGenerator (self)
 
def renderContents (self, encoding=DEFAULT_OUTPUT_ENCODING, prettyPrint=False, indentLevel=0)
 
def setString (self, string)
 
- Public Member Functions inherited from BeautifulSoup.PageElement
def append (self, tag)
 
def extract (self)
 
def findAllNext (self, name=None, attrs={}, text=None, limit=None, **kwargs)
 
def findAllPrevious (self, name=None, attrs={}, text=None, limit=None, **kwargs)
 
def findNext (self, name=None, attrs={}, text=None, **kwargs)
 
def findNextSibling (self, name=None, attrs={}, text=None, **kwargs)
 
def findNextSiblings (self, name=None, attrs={}, text=None, limit=None, **kwargs)
 
def findParent (self, name=None, attrs={}, **kwargs)
 
def findParents (self, name=None, attrs={}, limit=None, **kwargs)
 
def findPrevious (self, name=None, attrs={}, text=None, **kwargs)
 
def findPreviousSibling (self, name=None, attrs={}, text=None, **kwargs)
 
def findPreviousSiblings (self, name=None, attrs={}, text=None, limit=None, **kwargs)
 
def insert (self, position, newChild)
 
def nextGenerator (self)
 
def nextSiblingGenerator (self)
 
def parentGenerator (self)
 
def previousGenerator (self)
 
def previousSiblingGenerator (self)
 
def replaceWith (self, replaceWith)
 
def replaceWithChildren (self)
 
def setup (self, parent=None, previous=None)
 
def substituteEncoding (self, str, encoding=None)
 
def toEncoding (self, s, encoding=None)
 

Additional Inherited Members

- Public Attributes inherited from BeautifulSoup.BeautifulStoneSoup
 convertEntities
 
 convertHTMLEntities
 
 convertXMLEntities
 
 currentData
 
 currentTag
 
 declaredHTMLEncoding
 
 escapeUnrecognizedEntities
 
 fromEncoding
 
 hidden
 
 instanceSelfClosingTags
 
 literal
 
 markup
 
 markupMassage
 
 originalEncoding
 
 parseOnlyThese
 
 previous
 
 quoteStack
 
 smartQuotesTo
 
 tagStack
 
- Public Attributes inherited from BeautifulSoup.Tag
 attrMap
 
 attrs
 
 containsSubstitutions
 
 contents
 
 convertHTMLEntities
 
 convertXMLEntities
 
 escapeUnrecognizedEntities
 
 hidden
 
 isSelfClosing
 
 name
 
 parserClass
 
- Public Attributes inherited from BeautifulSoup.PageElement
 next
 
 nextSibling
 
 parent
 
 previous
 
 previousSibling
 
- Static Public Attributes inherited from BeautifulSoup.BeautifulStoneSoup
 ALL_ENTITIES
 
 HTML_ENTITIES
 
 MARKUP_MASSAGE
 
 NESTABLE_TAGS
 
 PRESERVE_WHITESPACE_TAGS
 
 QUOTE_TAGS
 
 RESET_NESTING_TAGS
 
 ROOT_TAG_NAME
 
 SELF_CLOSING_TAGS
 
 STRIP_ASCII_SPACES
 
 XHTML_ENTITIES
 
 XML_ENTITIES
 
- Static Public Attributes inherited from BeautifulSoup.Tag
 fetch
 
 findChild
 
 findChildren
 
 first
 
- Static Public Attributes inherited from BeautifulSoup.PageElement
 BARE_AMPERSAND_OR_BRACKET
 
 fetchNextSiblings
 
 fetchParents
 
 fetchPrevious
 
 fetchPreviousSiblings
 
 XML_ENTITIES_TO_SPECIAL_CHARS
 
 XML_SPECIAL_CHARS_TO_ENTITIES
 
- Properties inherited from BeautifulSoup.Tag
 string = property(getString, setString)
 
 text = property(getText)
 

Detailed Description

This class will push a tag with only a single string child into
the tag's parent as an attribute. The attribute's name is the tag
name, and the value is the string child. An example should give
the flavor of the change:

<foo><bar>baz</bar></foo>
 =>
<foo bar="baz"><bar>baz</bar></foo>

You can then access fooTag['bar'] instead of fooTag.barTag.string.

This is, of course, useful for scraping structures that tend to
use subelements instead of attributes, such as SOAP messages. Note
that it modifies its input, so don't print the modified version
out.

I'm not sure how many people really want to use this class; let me
know if you do. Mainly I like the name.

Definition at line 1675 of file BeautifulSoup.py.

Member Function Documentation

◆ popTag()

def BeautifulSoup.BeautifulSOAP.popTag (   self)

Reimplemented from BeautifulSoup.BeautifulStoneSoup.

Definition at line 1695 of file BeautifulSoup.py.

1695  def popTag(self):
1696  if len(self.tagStack) > 1:
1697  tag = self.tagStack[-1]
1698  parent = self.tagStack[-2]
1699  parent._getAttrMap()
1700  if (isinstance(tag, Tag) and len(tag.contents) == 1 and
1701  isinstance(tag.contents[0], NavigableString) and
1702  not parent.attrMap.has_key(tag.name)):
1703  parent[tag.name] = tag.contents[0]
1704  BeautifulStoneSoup.popTag(self)
1705 
1706 #Enterprise class names! It has come to our attention that some people
1707 #think the names of the Beautiful Soup parser classes are too silly
1708 #and "unprofessional" for use in enterprise screen-scraping. We feel
1709 #your pain! For such-minded folk, the Beautiful Soup Consortium And
1710 #All-Night Kosher Bakery recommends renaming this file to
1711 #"RobustParser.py" (or, in cases of extreme enterprisiness,
1712 #"RobustParserBeanInterface.class") and using the following
1713 #enterprise-friendly class aliases:

References BeautifulSoup.BeautifulStoneSoup.tagStack.