Skip to content

Instantly share code, notes, and snippets.

@chenpanliao
Created May 31, 2024 02:38
Show Gist options
  • Save chenpanliao/bdbbf7cf9ca5fd13d4a49c9fbc69f01c to your computer and use it in GitHub Desktop.
Save chenpanliao/bdbbf7cf9ca5fd13d4a49c9fbc69f01c to your computer and use it in GitHub Desktop.
library(rvest)
url <- "https://kuochang.tw/quote"
res <- read_html(url)
onion.quotations <-
res |>
html_elements("div.quoteCard") |>
html_elements("span.line") |>
html_text() |>
trimws() |>
(\(x) {gsub("[\t\n\r ,。]+", ",", x)})()
very.deep <-
function(comment = "", deep.level = 5) {
quotes <-
sample(onion.quotations, size = deep.level, replace = T) |>
paste(collapse = "\n")
res <- paste(comment, quotes, sep = "\n")
cat(res, "\n")
}
very.deep()
# 覺得經濟學人的記者,被民進黨餵了一堆假資訊
# 柯文哲:喊口號😐,不能改變這個國家😕
# 到底是在
# 可是藏在國民黨之中,背負多少罵名推進的
# 😏哼哼😀哈哈哈😃哈哈哈
very.deep("我跟你說齁", deep.level = 8)
# 我跟你說齁
# 別忘記,台灣民主化的推手,李登輝先生
# 經濟學人如果寫出這樣子的文章,我跟大家報告齁
# 🙌偽🙌君🙌子🙌的🙌冠🙌軍
# 😃喝喝喝😄呵呵呵
# ✋真小人跟✋偽君子到底,✊差在哪裡,
# 我話也不想說得太重
# 🫲但是因為黃國昌的存在,👋我已經分不出來,
# 👈猜猜看是誰,👈那絕對是,👈絕對是,黃,👈黃國昌
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment