Beautiful Soup Library
Making the Soup
Kinds of Objects
Beautiful Soup transforms a complex HTML document into a complex tree of Python objects.
Tag
A Tag object corresponds to an XML or HTML tag in the original document
Navigable String
A string corresponds to a bit of text within a tag. Beautiful Soup uses the NavigableString class to contain these bits of text.
Navigating the Tree
Going Down
Going Up
| Python | |
|---|---|
Going Sideways
| Python | |
|---|---|
Going Back and Forth
| Python | |
|---|---|
Searching the Tree
Filter Types
| Python | |
|---|---|
Methods
Methods arguments:
name(string): tag to search forattrs(dict): attribute-value pai to search forstring(string): search by string contents rather than by taglimit(int). limit number of results**kwargs: be turned into a filter on one of a tag's attributes.