Extract first element with XPath and scrapy
I use .extract() to get the data from a xpath, like: response.xpath('//*#id="bakery"]/span/text()').extract() the issue with this is that I always get a list as response. for example: ['23'] I only want the number, so I try with: response.xpath('//*#id="bakery"]/span/text()').extract() but this is a problem is the list empty, although I can use an exception to handle that scenario I guess there is a better way to do it
.extract_first() to the rescue: response.xpath('//*#id="bakery"]/span/text()').extract_first() Instead of an exception, it would return None if no elements were matched.
multiple string() results for an xpath?
XQuery/XPath: Using count() and max() function for return of element with highest count
Double iteration over a nodeset in XSLT-1.0
What is the correct XPath query for 'select onchange'
XPath 2.0: Retrieving nodes by attribute where value is case Insensitive
XPath - abbreviation of position() function
XPath Query in JMeter
xpath expression to select attribute value
DOMDocument xpath query cut off time
How to parse the following html code get all text before “br” tag
XPath selector by class AND index
How to perform set operations in XPath 1.0
extract data from a div that have no class using xpath
Xpath: Select node but not specific child elements
XQuery - How to use eq (=) on a group of values
better selenium xpath is expecting