Scrapy:star rating

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

我需要对此page进行爬网。我需要获得星级评分。

我已经尝试过

len(response.css('.c-pes-wait-time+ .c-pes-officestaff-performance').css('li:nth-child(1) .filled').xpath('//*[has-class("hg3-i hg3-i-star-full")]'))

HTML

<div class="c-pes-officestaff-performance">
      <div class="star-rating">
        <div class="empty">
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span></div>
        <div class="filled">
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span>
          <span class="hg3-i hg3-i-star-full"></span></div>
      </div>
  
python xpath web-scraping css-selectors
1个回答
0
投票

我在网站上看不到您的HTML,但这对我有用(使用Scrapy):

rating = response.xpath('//span[@data-id="js-section-review"]/button/span[1]/@aria-label').re_first(r'Rated (\d+)')
© www.soinside.com 2019 - 2024. All rights reserved.