Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- url[userID_, page_] := StringJoin[
- "https://api.stackexchange.com/2.2/users/",
- ToString[userID],
- "/reputation?page=",
- ToString[page],
- "&pagesize=100&site=mathematica&filter=!9YdnSQ3Rz"]
- Needs["GeneralUtilities`"];
- data[userID_, page_] := ToAssociations@Import[url[userID, page], "JSON"]
- next[userID_][old_] := With[{new = data[userID, ToExpression[old["page"]] + 1]},
- <|
- "items" -> Join[old["items"], new["items"]],
- "page" -> new["page"],
- "has_more" -> new["has_more"]
- |>
- ]
- res = NestWhile[
- next[121], <|"items" -> {}, "page" -> 0, "has_more" -> True|>,
- Slot["has_more"] &, 1, 10]["items"];
- UnitStep[#] # &[DeleteMissing[
- res[[All, "reputation_change"]]
- ] - 200] // Total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement