CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
BeautifulSoup.BeautifulSOAP Class Reference
Inheritance diagram for BeautifulSoup.BeautifulSOAP:
BeautifulSoup.BeautifulStoneSoup BeautifulSoup.BeautifulStoneSoup BeautifulSoup.Tag BeautifulSoup.Tag BeautifulSoup.Tag BeautifulSoup.Tag BeautifulSoup.PageElement BeautifulSoup.PageElement BeautifulSoup.PageElement BeautifulSoup.PageElement BeautifulSoup.PageElement BeautifulSoup.PageElement BeautifulSoup.PageElement BeautifulSoup.PageElement BeautifulSoup.SimplifyingSOAPParser BeautifulSoup.SimplifyingSOAPParser

Public Member Functions

def popTag
 
def popTag
 
- Public Member Functions inherited from BeautifulSoup.BeautifulStoneSoup
def __init__
 
def __init__
 
def endData
 
def endData
 
def extractCharsetFromMeta
 
def extractCharsetFromMeta
 
def handle_data
 
def handle_data
 
def isSelfClosingTag
 
def isSelfClosingTag
 
def popTag
 
def popTag
 
def pushTag
 
def pushTag
 
def reset
 
def reset
 
def unknown_endtag
 
def unknown_endtag
 
def unknown_starttag
 
def unknown_starttag
 
- Public Member Functions inherited from BeautifulSoup.PageElement
def append
 
def append
 
def extract
 
def extract
 
def findAllNext
 
def findAllNext
 
def findAllPrevious
 
def findAllPrevious
 
def findNext
 
def findNext
 
def findNextSibling
 
def findNextSibling
 
def findNextSiblings
 
def findNextSiblings
 
def findParent
 
def findParent
 
def findParents
 
def findParents
 
def findPrevious
 
def findPrevious
 
def findPreviousSibling
 
def findPreviousSibling
 
def findPreviousSiblings
 
def findPreviousSiblings
 
def insert
 
def insert
 
def nextGenerator
 
def nextGenerator
 
def nextSiblingGenerator
 
def nextSiblingGenerator
 
def parentGenerator
 
def parentGenerator
 
def previousGenerator
 
def previousGenerator
 
def previousSiblingGenerator
 
def previousSiblingGenerator
 
def replaceWith
 
def replaceWith
 
def setup
 
def setup
 
def substituteEncoding
 
def substituteEncoding
 
def toEncoding
 
def toEncoding
 

Additional Inherited Members

- Public Attributes inherited from BeautifulSoup.BeautifulStoneSoup
 builder
 
 convertEntities
 
 convertHTMLEntities
 
 convertXMLEntities
 
 currentData
 
 currentTag
 
 declaredHTMLEncoding
 
 escapeUnrecognizedEntities
 
 fromEncoding
 
 hidden
 
 instanceSelfClosingTags
 
 literal
 
 markup
 
 markupMassage
 
 originalEncoding
 
 parseOnlyThese
 
 previous
 
 quoteStack
 
 smartQuotesTo
 
 tagStack
 
- Public Attributes inherited from BeautifulSoup.PageElement
 next
 
 nextSibling
 
 parent
 
 previous
 
 previousSibling
 
- Static Public Attributes inherited from BeautifulSoup.BeautifulStoneSoup
 ALL_ENTITIES = XHTML_ENTITIES
 
string HTML_ENTITIES = "html"
 
list MARKUP_MASSAGE
 
dictionary NESTABLE_TAGS = {}
 
list PRESERVE_WHITESPACE_TAGS = []
 
dictionary QUOTE_TAGS = {}
 
dictionary RESET_NESTING_TAGS = {}
 
string ROOT_TAG_NAME = u'[document]'
 
dictionary SELF_CLOSING_TAGS = {}
 
dictionary STRIP_ASCII_SPACES = { 9: None, 10: None, 12: None, 13: None, 32: None, }
 
string XHTML_ENTITIES = "xhtml"
 
string XML_ENTITIES = "xml"
 
- Static Public Attributes inherited from BeautifulSoup.PageElement
 fetchNextSiblings = findNextSiblings
 
 fetchParents = findParents
 
 fetchPrevious = findAllPrevious
 
 fetchPreviousSiblings = findPreviousSiblings
 

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 1653 of file BeautifulSoup.py.

Member Function Documentation

def BeautifulSoup.BeautifulSOAP.popTag (   self)

Definition at line 1673 of file BeautifulSoup.py.

References BeautifulSoup.BeautifulStoneSoup.tagStack.

Referenced by BeautifulSoup.BeautifulSOAP.popTag().

1674  def popTag(self):
1675  if len(self.tagStack) > 1:
1676  tag = self.tagStack[-1]
1677  parent = self.tagStack[-2]
1678  parent._getAttrMap()
1679  if (isinstance(tag, Tag) and len(tag.contents) == 1 and
1680  isinstance(tag.contents[0], NavigableString) and
1681  not parent.attrMap.has_key(tag.name)):
1682  parent[tag.name] = tag.contents[0]
1683  BeautifulStoneSoup.popTag(self)
1684 
1685 #Enterprise class names! It has come to our attention that some people
1686 #think the names of the Beautiful Soup parser classes are too silly
1687 #and "unprofessional" for use in enterprise screen-scraping. We feel
1688 #your pain! For such-minded folk, the Beautiful Soup Consortium And
1689 #All-Night Kosher Bakery recommends renaming this file to
1690 #"RobustParser.py" (or, in cases of extreme enterprisiness,
1691 #"RobustParserBeanInterface.class") and using the following
#enterprise-friendly class aliases:
def BeautifulSoup.BeautifulSOAP.popTag (   self)

Definition at line 1673 of file BeautifulSoup.py.

References BeautifulSoup.BeautifulSOAP.popTag(), and BeautifulSoup.BeautifulStoneSoup.tagStack.

1674  def popTag(self):
1675  if len(self.tagStack) > 1:
1676  tag = self.tagStack[-1]
1677  parent = self.tagStack[-2]
1678  parent._getAttrMap()
1679  if (isinstance(tag, Tag) and len(tag.contents) == 1 and
1680  isinstance(tag.contents[0], NavigableString) and
1681  not parent.attrMap.has_key(tag.name)):
1682  parent[tag.name] = tag.contents[0]
1683  BeautifulStoneSoup.popTag(self)
1684 
1685 #Enterprise class names! It has come to our attention that some people
1686 #think the names of the Beautiful Soup parser classes are too silly
1687 #and "unprofessional" for use in enterprise screen-scraping. We feel
1688 #your pain! For such-minded folk, the Beautiful Soup Consortium And
1689 #All-Night Kosher Bakery recommends renaming this file to
1690 #"RobustParser.py" (or, in cases of extreme enterprisiness,
1691 #"RobustParserBeanInterface.class") and using the following
#enterprise-friendly class aliases: