1. 选择文字部分
XPATH:1
>>> response.xpath('//title/text()')
[<Selector (text) xpath=//title/text()>]
CSS:1
>>> response.css('title::text')
[<Selector (text) xpath=//title/text()>]
2. CSS选取节点下面的一个节点1
2<span itemscope="" itemtype="http://schema.org/Place">
<span>West Hampstead, London</span></span>
response.css('span[itemtype="http://schema.org/Place"] > span::text').extract()
参考:
3. 选取节点的某一个属性response.css('img[itemprop=image]::attr(scr)').extract()
4. 选取节点的文字部分response.css(".question_link::text").extract()
5. 当一个节点的class有几个部分的时候
d = response.css('.zh-general-list.clearfix::attr(data-init)').extract()