4 ms·
In my experience, it's not that CSS selectors are "more powerful," but rather "more legible." XPath is for sure more powerful, but also usually lower signal to
by mdaniel 4y ago
In my experience, it's not that CSS selectors are "more powerful," but rather "more legible." XPath is for sure more powerful, but also usually lower signal to noise ratio
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')]")