Overview
Scrapling provides intuitive methods to traverse the DOM tree. You can move up to parent elements, down to children, sideways to siblings, or iterate through ancestors.Parent Elements
parent
Access the direct parent of an element.None if the element has no parent.
iterancestors()
Iterate through all ancestor elements from parent to root.find_ancestor()
Find the first ancestor that matches a condition.Callable[[Selector], bool]
required
A function that takes each ancestor as an argument and returns True/False
None otherwise.
path
Get the full path from root to the current element.Selectors that contains the path leading to the current element from the root.
Children Elements
children
Get all direct children of an element.below_elements
Get all descendants (not just direct children) under the current element.Sibling Elements
siblings
Get all sibling elements (other children of the same parent).next
Get the next sibling element.None otherwise.
previous
Get the previous sibling element.None otherwise.