Skip to content

Instantly share code, notes, and snippets.

@uribo
Created February 15, 2024 05:02
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 uribo/c822bdf4f6cdaa47e744b5eef3318021 to your computer and use it in GitHub Desktop.
Save uribo/c822bdf4f6cdaa47e744b5eef3318021 to your computer and use it in GitHub Desktop.
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