Skip to content

Add funtion getchildren #596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

karan96108
Copy link

Add child node traversal methods to Element class

Problem

Currently users need to switch between requests-html and lxml.etree to work with child nodes,
creating unnecessary complexity.

Implementation

Added two methods to Element class:

  • children property - Returns list of direct child elements
  • getchildren() method - Provides lxml.etree compatibility

Breaking Changes

None. Adds new functionality while maintaining backwards compatibility.

Usage

# Using property
for child in element.children:
    print(child.tag)

# Using lxml-compatible method 
for child in element.getchildren():
    print(child.tag)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant