Public Member Functions | |
def | __getattr__ |
def | __init__ |
def | endData |
def | handle_charref |
def | handle_comment |
def | handle_data |
def | handle_decl |
def | handle_entityref |
def | handle_pi |
def | isSelfClosingTag |
def | parse_declaration |
def | popTag |
def | pushTag |
def | reset |
def | unknown_endtag |
def | unknown_starttag |
Public Attributes | |
convertEntities | |
currentData | |
currentTag | |
fromEncoding | |
hidden | |
instanceSelfClosingTags | |
literal | |
markup | |
markupMassage | |
originalEncoding | |
parseOnlyThese | |
previous | |
quoteStack | |
smartQuotesTo | |
tagStack | |
Static Public Attributes | |
string | HTML_ENTITIES = "html" |
list | MARKUP_MASSAGE |
dictionary | NESTABLE_TAGS = {} |
dictionary | QUOTE_TAGS = {} |
dictionary | RESET_NESTING_TAGS = {} |
string | ROOT_TAG_NAME = u'[document]' |
dictionary | SELF_CLOSING_TAGS = {} |
string | XML_ENTITIES = "xml" |
dictionary | XML_ENTITY_LIST = {} |
Private Member Functions | |
def | _feed |
def | _popToTag |
def | _smartPop |
def | _toStringSubclass |
This class contains the basic parser and search code. It defines a parser that knows nothing about tag behavior except for the following: You can't close a tag without closing all the tags it encloses. That is, "<foo><bar></foo>" actually means "<foo><bar></bar></foo>". [Another possible explanation is "<foo><bar /></foo>", but since this class defines no SELF_CLOSING_TAGS, it will never use that explanation.] This class is useful for parsing XML or made-up markup languages, or when BeautifulSoup makes an assumption counter to what you were expecting.
Definition at line 863 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.__init__ | ( | self, | |
markup = "" , |
|||
parseOnlyThese = None , |
|||
fromEncoding = None , |
|||
markupMassage = True , |
|||
smartQuotesTo = XML_ENTITIES , |
|||
convertEntities = None , |
|||
selfClosingTags = None |
|||
) |
The Soup object is initialized as the 'root tag', and the provided markup (which can be a string or a file-like object) is fed into the underlying parser. sgmllib will process most bad HTML, and the BeautifulSoup class has some tricks for dealing with some HTML that kills sgmllib, but Beautiful Soup can nonetheless choke or lose data if your data uses self-closing tags or declarations incorrectly. By default, Beautiful Soup uses regexes to sanitize input, avoiding the vast majority of these problems. If the problems don't apply to you, pass in False for markupMassage, and you'll get better performance. The default parser massage techniques fix the two most common instances of invalid HTML that choke sgmllib: <br/> (No space between name of closing tag and tag close) <! --Comment--> (Extraneous whitespace in declaration) You can pass in a custom list of (RE object, replace method) tuples to get Beautiful Soup to scrub your input the way you want.
Definition at line 901 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.__getattr__ | ( | self, | |
methodName | |||
) |
This method routes method call requests to either the SGMLParser superclass or the Tag superclass, depending on the method name.
Definition at line 977 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup._feed | ( | self, | |
inDocumentEncoding = None |
|||
) | [private] |
Definition at line 951 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup._popToTag | ( | self, | |
name, | |||
inclusivePop = True |
|||
) | [private] |
Pops the tag stack up to and including the most recent instance of the given tag. If inclusivePop is false, pops the tag stack up to but *not* including the most recent instqance of the given tag.
Definition at line 1048 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup._smartPop | ( | self, | |
name | |||
) | [private] |
We need to pop up to the previous tag of this type, unless one of this tag's nesting reset triggers comes between this tag and the previous tag of this type, OR unless this tag is a generic nesting trigger and another generic nesting trigger comes between this tag and the previous tag of this type. Examples: <p>Foo<b>Bar<p> should pop to 'p', not 'b'. <p>Foo<table>Bar<p> should pop to 'table', not 'p'. <p>Foo<table><tr>Bar<p> should pop to 'tr', not 'p'. <p>Foo<b>Bar<p> should pop to 'p', not 'b'. <li><ul><li> *<li>* should pop to 'ul', not the first 'li'. <tr><table><tr> *<tr>* should pop to 'table', not the first 'tr' <td><tr><td> *<td>* should pop to 'tr', not the first 'td'
Definition at line 1070 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup._toStringSubclass | ( | self, | |
text, | |||
subclass | |||
) | [private] |
Adds a certain piece of text to the tree as a NavigableString subclass.
Definition at line 1163 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.endData | ( | self, | |
containerClass = NavigableString |
|||
) |
Definition at line 1027 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.handle_charref | ( | self, | |
ref | |||
) |
Definition at line 1182 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.handle_comment | ( | self, | |
text | |||
) |
Definition at line 1178 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.handle_data | ( | self, | |
data | |||
) |
Definition at line 1160 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.handle_decl | ( | self, | |
data | |||
) |
Definition at line 1207 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.handle_entityref | ( | self, | |
ref | |||
) |
Handle entity references as data, possibly converting known HTML entity references to the corresponding Unicode characters.
Definition at line 1191 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.handle_pi | ( | self, | |
text | |||
) |
Handle a processing instruction as a ProcessingInstruction object, possibly one with a %SOUP-ENCODING% slot into which an encoding will be plugged later.
Definition at line 1170 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.isSelfClosingTag | ( | self, | |
name | |||
) |
Returns true iff the given string is the name of a self-closing tag according to this parser.
Definition at line 990 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.parse_declaration | ( | self, | |
i | |||
) |
Treat a bogus SGML declaration as raw data. Treat a CDATA declaration as a CData object.
Definition at line 1211 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.popTag | ( | self | ) |
Reimplemented in BeautifulSoup.BeautifulSOAP.
Definition at line 1006 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.pushTag | ( | self, | |
tag | |||
) |
Definition at line 1020 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.reset | ( | self | ) |
Definition at line 996 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.unknown_endtag | ( | self, | |
name | |||
) |
Definition at line 1147 of file BeautifulSoup.py.
def BeautifulSoup.BeautifulStoneSoup.unknown_starttag | ( | self, | |
name, | |||
attrs, | |||
selfClosing = 0 |
|||
) |
Definition at line 1117 of file BeautifulSoup.py.
Definition at line 924 of file BeautifulSoup.py.
Definition at line 996 of file BeautifulSoup.py.
Definition at line 996 of file BeautifulSoup.py.
Definition at line 924 of file BeautifulSoup.py.
Definition at line 996 of file BeautifulSoup.py.
string BeautifulSoup.BeautifulStoneSoup::HTML_ENTITIES = "html" [static] |
Definition at line 898 of file BeautifulSoup.py.
Definition at line 924 of file BeautifulSoup.py.
Definition at line 1117 of file BeautifulSoup.py.
Definition at line 924 of file BeautifulSoup.py.
list BeautifulSoup.BeautifulStoneSoup::MARKUP_MASSAGE [static] |
[(re.compile('(<[^<>]*)/>'), lambda x: x.group(1) + ' />'), (re.compile('<!\s+([^<>]*)>'), lambda x: '<!' + x.group(1) + '>') ]
Definition at line 890 of file BeautifulSoup.py.
Definition at line 924 of file BeautifulSoup.py.
dictionary BeautifulSoup.BeautifulStoneSoup::NESTABLE_TAGS = {} [static] |
Reimplemented in BeautifulSoup.MinimalSoup, BeautifulSoup.ICantBelieveItsBeautifulSoup, and BeautifulSoup.BeautifulSoup.
Definition at line 886 of file BeautifulSoup.py.
Reimplemented in BeautifulSoup.BeautifulSoup.
Definition at line 951 of file BeautifulSoup.py.
Definition at line 924 of file BeautifulSoup.py.
Reimplemented from BeautifulSoup.PageElement.
Definition at line 1027 of file BeautifulSoup.py.
dictionary BeautifulSoup.BeautifulStoneSoup::QUOTE_TAGS = {} [static] |
Reimplemented in BeautifulSoup.BeautifulSoup.
Definition at line 888 of file BeautifulSoup.py.
Definition at line 996 of file BeautifulSoup.py.
dictionary BeautifulSoup.BeautifulStoneSoup::RESET_NESTING_TAGS = {} [static] |
Reimplemented in BeautifulSoup.MinimalSoup, and BeautifulSoup.BeautifulSoup.
Definition at line 887 of file BeautifulSoup.py.
string BeautifulSoup.BeautifulStoneSoup::ROOT_TAG_NAME = u'[document]' [static] |
Definition at line 896 of file BeautifulSoup.py.
dictionary BeautifulSoup.BeautifulStoneSoup::SELF_CLOSING_TAGS = {} [static] |
Reimplemented in BeautifulSoup.BeautifulSoup.
Definition at line 885 of file BeautifulSoup.py.
Definition at line 924 of file BeautifulSoup.py.
Definition at line 996 of file BeautifulSoup.py.
string BeautifulSoup.BeautifulStoneSoup::XML_ENTITIES = "xml" [static] |
Definition at line 899 of file BeautifulSoup.py.
dictionary BeautifulSoup.BeautifulStoneSoup::XML_ENTITY_LIST = {} [static] |
Definition at line 881 of file BeautifulSoup.py.