如何使用 StackExchange API 从用户配置文件页面获取"top x% this y"?



使用StackExchange API,可以了解用户的很多信息:

{
"badge_counts": {
"bronze": 3,
"silver": 2,
"gold": 1
},
"view_count": 1000,
"down_vote_count": 50,
"up_vote_count": 90,
"answer_count": 10,
"question_count": 12,
"account_id": 1,
"is_employee": false,
"last_modified_date": 1625694512,
"last_access_date": 1625737712,
"reputation_change_year": 9001,
"reputation_change_quarter": 400,
"reputation_change_month": 200,
"reputation_change_week": 800,
"reputation_change_day": 100,
"reputation": 9001,
"creation_date": 1625694512,
"user_type": "registered",
"user_id": 1,
"accept_rate": 55,
"about_me": "about me block",
"location": "An Imaginary World",
"website_url": "http://example.com/",
"link": "http://example.stackexchange.com/users/1/example-user",
"profile_image": "https://www.gravatar.com/avatar/a007be5a61f6aa8f3e85ae2fc18dd66e?d=identicon&r=PG",
"display_name": "Example User"
}

此外,我想得到你在活动概述中找到的总声誉旁边的字符串,例如

top 5.43% this year

是否可以使用API以某种方式获取这些信息?

SE API和SEDE都不提供此类字段。相反,你可以

GET /users/rank?userId=<userId>

然后解析返回的HTML以获得所需的百分比。对于您(?user=353337(,它看起来像这样:

<a href="https://stackexchange.com/leagues/1/year/stackoverflow/2021-01-01/353337#353337" target="_blank">top <b>0.20%</b> this year</a>

相关内容

  • 没有找到相关文章

最新更新