【发布时间】:2014-03-01 18:47:42
【问题描述】:
请看这段 html 代码:
<header class="online">
<img src="http://static.flv.com/themes/h5/img/iconos/online.png"> <span>online</span>
<img src="http://static.flv.com/themes/h5/img/iconos/ojo16.png"> 428 <p>xxfantasia</p>
</header>
我想获取里面的文本(在本例中为 428)。我用这个:
def parse(self, response):
sel = Selector(response)
cams = sel.css('header.online')
for cam in cams:
print cam.css('text').extract()
我认为我使用了正确的 css 选择器,但结果为空。
有什么帮助吗?
【问题讨论】:
标签: python css python-2.7 css-selectors scrapy