Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions requests_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from concurrent.futures._base import TimeoutError
from functools import partial
from typing import Set, Union, List, MutableMapping, Optional
from typing import List

import pyppeteer
import requests
Expand Down Expand Up @@ -388,6 +389,15 @@ def __repr__(self) -> str:
return "<Element {} {}>".format(repr(self.element.tag), ' '.join(attrs))

@property
def children(self) -> List['Element']:

"""Returns a list of child elements."""
return [Element(element=child, url=self.url, default_encoding=self.default_encoding)
for child in self.element.getchildren()]

def getchildren(self) -> List['Element']:
"""Returns a list of child elements (lxml compatibility method)."""
return self.children
def attrs(self) -> _Attrs:
Comment on lines 391 to 401

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @karan96108, just found this PR by chance. Would suggest this change:

Suggested change
@property
def children(self) -> List['Element']:
"""Returns a list of child elements."""
return [Element(element=child, url=self.url, default_encoding=self.default_encoding)
for child in self.element.getchildren()]
def getchildren(self) -> List['Element']:
"""Returns a list of child elements (lxml compatibility method)."""
return self.children
def attrs(self) -> _Attrs:
@property
def children(self) -> List['Element']:
"""Returns a list of child elements."""
return [Element(element=child, url=self.url, default_encoding=self.default_encoding)
for child in self.element.getchildren()]
def getchildren(self) -> List['Element']:
"""Returns a list of child elements (lxml compatibility method)."""
return self.children
@property
def attrs(self) -> _Attrs:

"""Returns a dictionary of the attributes of the :class:`Element <Element>`
(`learn more <https://www.w3schools.com/tags/ref_attributes.asp>`_).
Expand Down