在此page上,我试图找到星级。
在刮scrap的外壳中:
len(response.css('#info-panel .selected'))
len(response.css('#info-panel').xpath('//*[has-class("star selected")]'))
但是没有任何结果。
html
<div class="search-item-info" doctordetail=".1.0.0.0.1.3">
<span doctordetail=".1.0.0.0.1.3.0">
<span class="star-rating" title="3.92" doctordetail=".1.0.0.0.1.3.0.0">
<span class="stars" doctordetail=".1.0.0.0.1.3.0.0.0">
<span class="star" doctordetail=".1.0.0.0.1.3.0.0.0.$5"></span>
<span class="star selected" doctordetail=".1.0.0.0.1.3.0.0.0.$4"></span>
<span class="star selected" doctordetail=".1.0.0.0.1.3.0.0.0.$3"></span>
<span class="star selected" doctordetail=".1.0.0.0.1.3.0.0.0.$2"></span>
<span class="star selected" doctordetail=".1.0.0.0.1.3.0.0.0.$1"></span></span>
</span>
<div class="star-rating-count" doctordetail=".1.0.0.0.1.3.0.1">
<span doctordetail=".1.0.0.0.1.3.0.1.0">
<span itemprop="ratingCount" doctordetail=".1.0.0.0.1.3.0.1.0.0">28</span></span>
<span doctordetail=".1.0.0.0.1.3.0.1.1"> reviews</span></div>
</span>
</div>
尝试此
response.css(".star-rating::attr(title)").get()