From b4593c2ae75eb9d5c681631b3f6fc889e13b31e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Thu, 24 Apr 2014 00:11:42 -0300 Subject: [PATCH] document shortcuts in TextResponse class --- docs/topics/request-response.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 --------------------