diff --git a/requests_html.py b/requests_html.py index cd341def..3cfecbc0 100644 --- a/requests_html.py +++ b/requests_html.py @@ -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 @@ -388,6 +389,15 @@ def __repr__(self) -> str: return "".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: """Returns a dictionary of the attributes of the :class:`Element ` (`learn more `_).