This week's winners!

I'm obviously not @hadley, but I wanted an excuse to try parsing some JSON:

library(httr)
suppressPackageStartupMessages(library(tidyverse))

url <- "https://forum.posit.co/t/1230.json"

req <- httr::GET(url)
stop_for_status(req)
con <- httr::content(req)

url2 <- paste0(
  "https://forum.posit.co/t/1230/posts.json?",
  paste0("post_ids%5B%5D=", con$post_stream$stream, collapse = "&")
  )

req2 <- httr::GET(url2)
stop_for_status(req2)
con2 <- httr::content(req2)


winners <- con2$post_stream$posts %>%
  keep(~ .$username == "Bill") %>%
  map_chr("cooked") %>%
  stringr::str_match_all("href=\\\"/u/(\\w+)\\\"") %>%
  map(~ .[,2]) %>%
  flatten_chr()

winners
#>  [1] "mara"          "alistaire"     "daattali"      "emilyriederer"
#>  [5] "eric_bickel"   "nick"          "jessemaegan"   "raybuhr"      
#>  [9] "billr"         "mmuurr"        "hadley"        "apreshill"    
#> [13] "pavopax"       "mfherman"      "rensa"         "tomtec"       
#> [17] "economicurtis" "pssguy"        "cdr6934"       "rpodcast"     
#> [21] "andrea"        "timpe"         "cderv"         "pirategrunt"  
#> [25] "mungojam"      "rkahne"        "davergp"

Filtering the subsequent candidate list is straightforward. It depends on @bill not @mentioning any non-winners in this thread. Only one false positive at the moment, and @hadley can't win anyway!

2017-10-20 Edit: Fixed code to pull in more than 20 posts

2 Likes