擅长:python、mysql、java
<p>如果我正确理解您的问题和评论,以下内容应摘录该页面中的所有评分:</p>
<pre><code>import lxml.html
import requests
BASE_URL = "https://webscraper.io/test-sites/e-commerce/allinone/computers/laptops"
html = requests.get(BASE_URL)
root = lxml.html.fromstring(html.text)
targets = root.xpath('//p[./span[@class]]/@data-rating')
</code></pre>
<p>例如:</p>
<pre><code>targets[0]
</code></pre>
<p>输出</p>
<blockquote>
<p>3</p>
</blockquote>