Ammend example nesting selectors

This commit is contained in:
Daniel Graña 2014-04-24 10:32:17 -03:00
parent b4593c2ae7
commit 18412d75b5
1 changed files with 10 additions and 3 deletions

View File

@ -121,10 +121,17 @@ convenient shortcuts: ``response.xpath()`` and ``response.css()``::
[<Selector (text) xpath=//title/text()>]
>>> response.css('title::text')
[<Selector (text) xpath=//title/text()>]
As you can see, the ``.xpath()`` and ``.css()`` methods returns an
As you can see, ``.xpath()`` and ``.css()`` methods returns an
:class:`~scrapy.selector.SelectorList` instance, which is a list of new
selectors. This API can be used quickly for extracting nested data.
selectors. This API can be used quickly for selecting nested data::
>>> response.css('img').xpath('@src').extract()
[u'image1_thumb.jpg',
u'image2_thumb.jpg',
u'image3_thumb.jpg',
u'image4_thumb.jpg',
u'image5_thumb.jpg']
To actually extract the textual data, you must call the selector ``.extract()``
method, as follows::