From ca8d60f2670adfba80fa1ef55446ed7f3463edca Mon Sep 17 00:00:00 2001 From: Hoat Le Date: Wed, 7 Oct 2015 15:43:02 +0700 Subject: [PATCH] fix ValueError: Invalid XPath: //div/[id="not-exists"]/text() on selectors.rst >>> response.xpath('//div/[id="not-exists"]/text()').extract_first() is None Traceback (most recent call last): File "", line 1, in File "/home/vagrant/.virtualenvs/scrapy/lib/python2.7/site-packages/scrapy/http/response/text.py", line 109, in xpath return self.selector.xpath(query) File "/home/vagrant/.virtualenvs/scrapy/lib/python2.7/site-packages/scrapy/selector/unified.py", line 100, in xpath raise ValueError(msg if six.PY3 else msg.encode("unicode_escape")) ValueError: Invalid XPath: //div/[id="not-exists"]/text() --- docs/topics/selectors.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/topics/selectors.rst b/docs/topics/selectors.rst index 688c2b715..9d19506d2 100644 --- a/docs/topics/selectors.rst +++ b/docs/topics/selectors.rst @@ -146,7 +146,7 @@ If you want to extract only first matched element, you can call the selector ``. It returns ``None`` if no element was found: - >>> response.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``: