xpath中extract()使用


title = response.xpath("//div[@class='entry-header']/h1/text()")
title = response.xpath("//div[@class='entry-header']/h1/text()").extract()
title = response.xpath("//div[@class='entry-header']/h1/text()").extract()[0]
title = response.xpath("//div[@class='entry-header']/h1/text()")[0].extract()
title = response.xpath("//div[@class='entry-header']/h1/text()")[0].extract()[0]
 

返回一个SelectorList对象 http://scrapy-chs.readthedocs.io/zh_CN/0.24/topics/selectors.html#selectorlist
返回一个list
返回list中的第一个元素
返回SelectorList中的第一个元素(如果list为空抛出异常),返回的是一str类型,与3效果相同
返回SelectorList中的第一个元素中的第一个字符


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM