Scrapy, a fast high-level web crawling & scraping framework for Python.
feat: Add support for the Parsel JMESPath
Jalil SA9af596a6b806
diff --git a/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.pyindex 4213d491d..a82ed834a 100644--- a/scrapy/http/response/__init__.py+++ b/scrapy/http/response/__init__.py@@ -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 contentis text (subclasses of TextResponse).diff --git a/scrapy/http/response/text.py b/scrapy/http/response/text.pyindex 73bb811de..360d6334e 100644--- a/scrapy/http/response/text.py+++ b/scrapy/http/response/text.py@@ -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)