diff --git a/docs/source/index.rst b/docs/source/index.rst index 3ddc900..1e891d7 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -103,7 +103,19 @@ Render out an :class:`Element `'s HTML: >>> about.html '
  • \nAbout\n\n
  • ' +Crab an :class:`Element `'s root tag name: +.. code-block:: pycon + + >>> about.tag + 'li' + +Show the line number that an :class:`Element `'s root tag located in: + +.. code-block:: pycon + + >>> about.lineno + 249 Select an :class:`Element ` list within an :class:`Element `: diff --git a/requests_html.py b/requests_html.py index 0ab0a57..cce2abb 100644 --- a/requests_html.py +++ b/requests_html.py @@ -378,6 +378,8 @@ class Element(BaseParser): def __init__(self, *, element, url: _URL, default_encoding: _DefaultEncoding = None) -> None: super(Element, self).__init__(element=element, url=url, default_encoding=default_encoding) self.element = element + self.tag = element.tag + self.lineno = element.sourceline self._attrs = None def __repr__(self) -> str: