mirror of https://github.com/scrapy/scrapy.git
feat: Add support for the Parsel JMESPath
This commit is contained in:
parent
8c8fb67057
commit
9af596a6b8
|
|
@ -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).
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue