Fix extract_first() docs

This commit is contained in:
Mateusz Golewski 2014-02-02 15:02:25 +01:00 committed by Julia Medina
parent 012211accd
commit 127c6c694a
1 changed files with 5 additions and 5 deletions

View File

@ -139,15 +139,15 @@ method, as follows::
>>> response.xpath('//title/text()').extract()
[u'Example website']
If you want to extract only first matched element, you must call the selector ``.extract_first()``
If you want to extract only first matched element, you can call the selector ``.extract_first()``
>>> sel.xpath('//ul/li').extract_first()
u'First list element'
>>> sel.xpath('//div[@id="images"]/a/text()').extract_first()
u'Name: My image 1 '
It returns ``None`` if no element was found:
>>> sel.xpath('//ul/li[999]').extract_first()
None
>>> sel.xpath('//div/[id="not-exists"]/text()').extract_first() is None
True
Notice that CSS selectors can select text or attribute nodes using CSS3
pseudo-elements::