Add docs for extract_first()

This commit is contained in:
Mateusz Golewski 2014-01-30 23:39:15 +01:00 committed by Julia Medina
parent 2742b4d8c2
commit 012211accd
1 changed files with 10 additions and 0 deletions

View File

@ -139,6 +139,16 @@ 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()``
>>> sel.xpath('//ul/li').extract_first()
u'First list element'
It returns ``None`` if no element was found:
>>> sel.xpath('//ul/li[999]').extract_first()
None
Notice that CSS selectors can select text or attribute nodes using CSS3
pseudo-elements::