Skip to content

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

Merge pull request #1145 from bosnj/master

Mikhail Korobovcc2258b2bbdb
diff --cc docs/topics/selectors.rst
index 0d82494a4,f8a9b0410..bd4135b34
--- a/docs/topics/selectors.rst
+++ b/docs/topics/selectors.rst
@@@ -146,9 -146,14 +146,14 @@@ If you want to extract only first match
It returns ``None`` if no element was found:
- >>> sel.xpath('//div/[id="not-exists"]/text()').extract_first() is None
+ >>> response.xpath('//div/[id="not-exists"]/text()').extract_first() is None
True
+ A default return value can be provided as an argument, to be used instead of ``None``:
+
+ >>> sel.xpath('//div/[id="not-exists"]/text()').extract_first(default='not-found')
+ 'not-found'
+
Notice that CSS selectors can select text or attribute nodes using CSS3
pseudo-elements::