寻星评级

问题描述 投票:1回答:1

在此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>
python xpath web-scraping scrapy css-selectors
1个回答
0
投票

尝试此

response.css(".star-rating::attr(title)").get()
© www.soinside.com 2019 - 2024. All rights reserved.