Quick reference
The following commands will help you to navigate down the tree:
tag.name
: This navigates to the child using the nametag.contents
: This lists the childrentag.children
: This is a generator for childrentag.descendants
: This is a generator for descendantstag.string
: This navigates to a string using.string
tag.strings
: This is a generator for strings
The following commands will help you to navigate up the tree:
tag.parent
: This navigates to the parenttag.parents
: This is a generator for parents
The following commands will help you to navigate sideways:
tag.next_sibling
: This navigates to the next siblingtag.next_siblings
: This is a generator for next siblingstag.previous_sibling
: This navigates to the previous siblingtag.previous_siblings ...
Get Getting Started with Beautiful Soup now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.