Selectors comparison
Initialising
Selectors
xxs = XmlXPathSelector(response)
hxs = HtmlXpathSelector(response)
Lxml
xml_tree = lxml.etree.fromstring(response)
html_tree = lxml.html.fromstring(response)
Selecting
Selectors
Lxml
html_tree.xpath('//p')
html_tree.cssselect('p')
Selectors
hxs.select('//div[@id="id"/p').extract()
Lxml
res = html_tree.xpath('//div[@id="id"/p')
[lxml.etree.tostring(e) for e in res]
Selecting text directly
Selectors
hxs.select('//p/text()').extract()
Lxml
html_tree.xpath('//p/text()')