Skip to content

Instantly share code, notes, and snippets.

@jthomasmock
Created February 26, 2023 17:20
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 jthomasmock/10e217dab119bccb7df8d6d0aa483dab to your computer and use it in GitHub Desktop.
Save jthomasmock/10e217dab119bccb7df8d6d0aa483dab to your computer and use it in GitHub Desktop.
```{r write-tags}
#| echo: false
library(rvest)
library(xml2)
raw_html <- read_html(here::here("_site/index.html"))
length_tags <- raw_html |>
html_nodes("#quarto-margin-sidebar > div > div") |>
length()
all_tags <- sapply(seq_len(length_tags), function(x){
html_nodes(raw_html, xpath = glue::glue('//*[@id="quarto-margin-sidebar"]/div/div[{x}]/text()')) |>
html_text(trim = TRUE)
})
all_tags[all_tags != "All"] |>
write_lines(here::here("_data/unique_categories.txt"))
```
# Gist URL https://gist.github.com/10e217dab119bccb7df8d6d0aa483dab
# Code image at: ![](https://i.imgur.com/jAQJlNS.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment