I was reading another thread about webscraping, someone mentioned CSS selectors being way quicker than xpath. I'm easy either way but apart from a more powerful syntax what other benefits are there?
response.css("#the-id")
# vs
response.xpath("//*[@id='the-id']")
Thankfully, Scrapy (well, pedantically "parsel") allows mixing and matching, using the one which makes the most sense response.css(".someClass").xpath(".//*[starts-with(text(), 'Price')]")XPATH is generally more powerful for really gnarly things and for backtracking. "Show me the 3rd paragraph that's a sibling of the fourth div id="subhed" and contains the text "starting".
> XPATH is generally more powerful...
That is a convincing argument is you can back it up with an XPATH expression.Hell, even "find id=subhead and _go up one element_" isn't possible in CSS because that's not a problem it was designed to solve
This is in the context of test automation of modern web apps with a virtual DOM. I'm sure things might be different in other areas.