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