lxml xpath 不工作

lxml xpath not working

我正在尝试解析下面的网页代码。 我能够让用户使用 xpath 但我无法使用 xpath 获得他们的分数任何想法我在这里做错了什么?

import requests
from lxml import html

internsHack = 'https://doselect.com/hackathon/inmobi-internshack/leaderboard'

page = requests.get(internsHack)
tree = html.fromstring(page.content)

users = tree.xpath('//div[@class="md-list-item-text"]/h2/a/text()')
score = tree.xpath('//div[@class="points-score"]/ng-pluralize/text()')

HTML 源代码片段:

<div class="points-score">
  <ng-pluralize count="200"
                           when="{'0': '{} point',
                               'one': '{} point',
                               'other': '{} points'}">
</div>

获取 count 属性值而不是 text():

//div[@class="points-score"]/ng-pluralize/@count

score 变量将具有以下值:

['200', '198', '198', '197', '197', '197', '196', '195', '194', '194']