Created
November 17, 2019 14:32
-
-
Save hoxo-m/96cc5c16c7421a26df0b5d795ade4417 to your computer and use it in GitHub Desktop.
Qiita の Organization のメンバーIDを取得する関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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