选择器
Scrapy selector是以 文字(text) 或 TextResponse 构造的 Selector 实例。 其根据输入的类型自动选择最优的分析方法(XML vs HTML):
from scrapy.selector import Selector
from scrapy.http import HtmlResponse
#文字选择器构造
body = '<html><body><span>good</span></body></html>'
Selector(text=body).xpath('//span/text()').extract()
[u'good']
#response构造
response = HtmlResponse(url='http://example.com',body=body)
Selector(response=response).xpath('//span/text()').extract()
response.selector.xpath()才是真正的方法
xpath() #根据xapth方法
css() #根据css选择器
re() #根据正则
extract() #将结果串行化到一个列表
官方文档是学习的最好资料