Skip to content

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

Fix extract_first() docs

Mateusz Golewski127c6c694a75
diff --git a/docs/topics/selectors.rst b/docs/topics/selectors.rst
index 0ce0f084e..92e092246 100644
--- a/docs/topics/selectors.rst
+++ b/docs/topics/selectors.rst
@@ -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::