Skip to content

Instantly share code, notes, and snippets.

@uribo
Last active August 29, 2015 14:10
Show Gist options
  • Save uribo/ec45b61b8e83891a0611 to your computer and use it in GitHub Desktop.
Save uribo/ec45b61b8e83891a0611 to your computer and use it in GitHub Desktop.
Generate Dribbble color palette form genre
get_shot_palette <- function (col.n = 8, genre = c("debut", "recent", "teams", "playoffs", "animated")) {
base.url <- c("https://dribbble.com")
request.url <- html(paste(base.url, "/shots?list=", genre, sep = "")) %>%
html_nodes(".dribbble-img a") %>%
html_attr("href") %>%
head(1)
request.url <-paste(base.url, request.url, sep = "")
url <- html(request.url)
cols <- url %>%
html_nodes("ul.color-chips li a") %>%
html_attr("title")
cols[1:col.n]
na.omit(cols)
}
# 'usage
# get_shot_palette(genre = "debut")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment