我需要对此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>
我在网站上看不到您的HTML,但这对我有用(使用Scrapy):
rating = response.xpath('//span[@data-id="js-section-review"]/button/span[1]/@aria-label').re_first(r'Rated (\d+)')