如何使用Scrapy找出类名中带有“on”一词的类的数量
<div class="listing item-rating" style="display: block;">
<img src="/Content/images/spacer.gif" class="star-left on">
<img src="/Content/images/spacer.gif" class="star-right on">
<img src="/Content/images/spacer.gif" class="star-left on">
<img src="/Content/images/spacer.gif" class="star-right of">
<img src="/Content/images/spacer.gif" class="star-left of">
<img src="/Content/images/spacer.gif" class="star-left of">
</div>
response.xpath('//*[has-class("on")]')
提供选择器(所有具有“on”的类)len(response.xpath('//*[has-class("on")]'))
给出了长度——在本例中是类的数量相关问题 更多 >
编程相关推荐