Reputation: 333
I am trying to parse a webpage code for which is below. I am able to get the users using the xpath but i am unable to get their scores using xpath any ideas what i am doing wrong here ?
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()')
Upvotes: 2
Views: 800
Reputation: 473753
HTML source snippet:
<div class="points-score">
<ng-pluralize count="200"
when="{'0': '{} point',
'one': '{} point',
'other': '{} points'}">
</div>
Get the count
attribute values instead of text()
:
//div[@class="points-score"]/ng-pluralize/@count
score
variable would then have the following value:
['200', '198', '198', '197', '197', '197', '196', '195', '194', '194']
Upvotes: 2