def xpath(self, selector: str, *, clean: bool = False, first: bool = False, _encoding: str = None) -> _XPath:
selected = self.lxml.xpath(selector)<EOL>elements = [<EOL>Element(element=selection, url=self.url, default_encoding=_encoding or self.encoding)<EOL>if not isinstance(selection, etree._ElementUnicodeResult) else str(selection)<EOL>for selection in selected<EOL>]<EOL>if clean:<EOL><INDENT>elements_copy = elements.copy()<EOL>elements = []<EOL>for element in elements_copy:<EOL><INDENT>element.raw_html = lxml_html_tostring(cleaner.clean_html(element.lxml))<EOL>elements.append(element)<EOL><DEDENT><DEDENT>return _get_first_or_list(elements, first)<EOL>
Given an XPath selector, returns a list of
        :class:`Element <Element>` objects or a single one.

        :param selector: XPath Selector to use.
        :param clean: Whether or not to sanitize the found HTML of ``<script>`` and ``<style>`` tags.
        :param first: Whether or not to return just the first result.
        :param _encoding: The encoding format.

        If a sub-selector is specified (e.g. ``//a/@href``), a simple
        list of results is returned.

        See W3School's `XPath Examples
        <https://www.w3schools.com/xml/xpath_examples.asp>`_
        for more details.

        If ``first`` is ``True``, only returns the first
        :class:`Element <Element>` found.