首页 > 代码库 > 【Scrapy】Selectors

【Scrapy】Selectors

Constructing selectors

For convenience,response objects exposes a selector on .selector attribute,it‘s totally ok to use this shortcut when possible.

//怎么构造selector?

response.selector.xpath(‘...‘)可以简写成response.xpath()

xpath()方法返回的是a list of selectors.

在一个xpath()返回的selector中嵌套使用selector,此时//默认是整个文档,要想是相对路径,需要是.//