Created
February 15, 2024 05:02
-
-
Save uribo/c822bdf4f6cdaa47e744b5eef3318021 to your computer and use it in GitHub Desktop.
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(httr2) | |
library(rvest) | |
# ページリスト ------------------------------------------------------------------ | |
req <- | |
request("https://scrapbox.io/") |> | |
req_url_path_append("api/pages/") |> | |
req_url_path_append("mandaRa") | |
x <- | |
req |> | |
req_perform() |> | |
resp_body_json() | |
cat(glue::glue("総ページ数: {x$count}\n")) | |
# [todo] 100ページをこえた場合は、次のページを取得するように | |
# skipとlimitパラメータを使って制御 | |
df_pages <- | |
tibble::tibble( | |
name = x$pages |> | |
purrr::map_chr("title") | |
) | |
# lubridate::as_datetime(x$pages[[1]]$updated) |> | |
# lubridate::with_tz("Asia/Tokyo") | |
# ページ --------------------------------------------------------------------- | |
# /api/pages/:projectName/:pageTitle | |
x <- | |
req |> | |
req_url_path_append(df_pages$name[1]) |> | |
req_perform() |> | |
resp_body_json() | |
x |> names() |> dput() | |
# c("id", "title", "image", "descriptions", "user", "pin", "views", | |
# "linked", "commitId", "created", "updated", "accessed", "snapshotCreated", | |
# "pageRank", "lastAccessed", "persistent", "lines", "links", "projectLinks", | |
# "icons", "files", "relatedPages", "collaborators") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment