你的xpath查询错误
for entry in sel.xpath("//div[@]"):在这一行中,你实际上是在对没有任何Href属性的div进行迭代
为了使其正确,你应该在中选择
achor元素
div:
for entry in sel.xpath("//div[@]/a"): print entry.xpath('href').extract()最好的解决方案是直接href在for循环中提取属性
for href in sel.xpath("//div[@]/a/@href").extract(): print hrefa
为了简单起见,你还可以使用CSS选择器
for href in sel.css("div.recipe-description a::attr(href)").extract(): print href


