feat: Add support for the Parsel JMESPath

This commit is contained in:
Jalil SA 2023-04-25 10:24:14 -05:00
parent 8c8fb67057
commit 9af596a6b8
2 changed files with 9 additions and 0 deletions

View File

@ -142,6 +142,12 @@ class Response(object_ref):
"""
raise NotSupported("Response content isn't text")
def jmespath(self, *a, **kw):
"""Shortcut method implemented only by responses whose content
is text (subclasses of TextResponse).
"""
raise NotSupported("Response content isn't text")
def xpath(self, *a, **kw):
"""Shortcut method implemented only by responses whose content
is text (subclasses of TextResponse).

View File

@ -139,6 +139,9 @@ class TextResponse(Response):
self._cached_selector = Selector(self)
return self._cached_selector
def jmespath(self, query, **kwargs):
return self.selector.jmespath(query, **kwargs)
def xpath(self, query, **kwargs):
return self.selector.xpath(query, **kwargs)