Skip to content

Instantly share code, notes, and snippets.

@hoxo-m
Created November 17, 2019 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoxo-m/96cc5c16c7421a26df0b5d795ade4417 to your computer and use it in GitHub Desktop.
Save hoxo-m/96cc5c16c7421a26df0b5d795ade4417 to your computer and use it in GitHub Desktop.
Qiita の Organization のメンバーIDを取得する関数
library(tidyverse)
library(rvest)
qiita_get_organization_member <- function(organization) {
target_url <- str_glue("https://qiita.com/organizations/{organization}/members")
sess <- html_session(target_url)
member_ids <- c()
while (!is.null(sess)) {
ids <- sess %>%
html_nodes(xpath = "//*[@class='od-MemberCardHeaderIdentities_userid']") %>%
html_text() %>%
str_remove("@")
member_ids <- append(member_ids, ids)
sess <- tryCatch(
sess %>% follow_link(xpath = "//*[@class='st-Pager_next']/a"),
error = function(e) return(NULL)
)
}
member_ids
}
qiita_get_organization_member("mercari")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment