Advertisement
Guest User

Untitled

a guest
Aug 19th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. url[userID_, page_] := StringJoin[
  2. "https://api.stackexchange.com/2.2/users/",
  3. ToString[userID],
  4. "/reputation?page=",
  5. ToString[page],
  6. "&pagesize=100&site=mathematica&filter=!9YdnSQ3Rz"]
  7. Needs["GeneralUtilities`"];
  8. data[userID_, page_] := ToAssociations@Import[url[userID, page], "JSON"]
  9. next[userID_][old_] := With[{new = data[userID, ToExpression[old["page"]] + 1]},
  10. <|
  11. "items" -> Join[old["items"], new["items"]],
  12. "page" -> new["page"],
  13. "has_more" -> new["has_more"]
  14. |>
  15. ]
  16. res = NestWhile[
  17. next[121], <|"items" -> {}, "page" -> 0, "has_more" -> True|>,
  18. Slot["has_more"] &, 1, 10]["items"];
  19.  
  20. UnitStep[#] # &[DeleteMissing[
  21. res[[All, "reputation_change"]]
  22. ] - 200] // Total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement