Extracting data from Twitter for @hrbrmstr's #nom foodie images
Rendered on: 2018-01-16
Bob Rudis (@hrbrmstr) is a famed expert, author and developer in Data Security and the Chief Security Data Scientist at Rapid7. Bob also creates the most deliciously vivid images of his meals documented by the #nom hashtag. I'm going to use a similar method used in my previous projects (Hipster Veggies & Machine Learning Flashcards) to wrangle all those images into a nice collection - mostly for me to look at for inspiration in recipe planning.
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>Yum! Have you ever thought about collecting all these recipes & images into a cookbook?!
— Jasmine Dumas (@jasdumas) January 15, 2018
Source Repository: jasdumas/bobs-noms
Analysis
library(rtweet) # devtools::install_github("mkearney/rtweet")
library(tidyverse)
library(dplyr)
library(stringr)
library(magick)
library(knitr)
library(kableExtra)
# get all of bob's recent tweets
bobs_tweets <- get_timeline(user = "hrbrmstr", n = 3200)
#filter noms with images only
bobs_noms <-
bobs_tweets %>% dplyr::filter(str_detect(hashtags, "nom"), !is.na(media_url))
bobs_noms$clean_text <- bobs_noms$text
bobs_noms$clean_text <- str_replace(bobs_noms$clean_text,"#[a-zA-Z0-9]{1,}", "") # remove the hashtag
bobs_noms$clean_text <- str_replace(bobs_noms$clean_text, " ?(f|ht)(tp)(s?)(://)(.*)[.|/](.*)", "") # remove the url link
bobs_noms$clean_text <- str_replace(bobs_noms$clean_text, "[[:punct:]]", "") # remove punctuation
# let's look at these images in a smaller data set
bobs_noms_small <- bobs_noms %>% select(created_at, clean_text, media_url)
bobs_noms_small$img_md <- paste0("")
bobs_noms_small$img_md %>%
kable( format = "html") %>%
kable_styling(bootstrap_options = "striped",
full_width = F)
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
}
cat("saved images...\n")
}
save_image(bobs_noms)
## saved images...
Contact Me
Jasmine Dumas | [@jasdumas](https://twitter.com/jasdumas) | jasdumas.github.io