如何使用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")]'))
为您提供长度-在这种情况下,是课程数量