Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

document shortcuts in TextResponse class

Daniel Grañab4593c2ae75e
diff --git a/docs/topics/request-response.rst b/docs/topics/request-response.rst
index cda074a71..11eb0dd08 100644
--- a/docs/topics/request-response.rst
+++ b/docs/topics/request-response.rst
@@ -526,6 +526,11 @@ TextResponse objects
4. the encoding inferred by looking at the response body. This is the more
fragile method but also the last one tried.
+ .. attribute:: TextResponse.selector
+
+ A :class:`~scrapy.selector.Selector` instance using the response as
+ target. The selector is lazily instantiated on first access.
+
:class:`TextResponse` objects support the following methods in addition to
the standard :class:`Response` ones:
@@ -543,6 +548,19 @@ TextResponse objects
(typically `ascii`) to convert the body to unicode, instead of the response
encoding.
+ .. method:: TextResponse.xpath(query)
+
+ A shortcut to ``TextResponse.selector.xpath(query)``::
+
+ response.xpath('//p')
+
+ .. method:: TextResponse.css(query)
+
+ A shortcut to ``TextResponse.selector.css(query)``::
+
+ response.css('p')
+
+
HtmlResponse objects
--------------------