Web Scraping: L.L.Bean
page <- read_html("https://www.llbean.com")
# Title tag
title_tag <- page %>%
html_element("title") %>%
html_text2() %>%
str_squish()
title_tag
## [1] "L.L.Bean - Outside Together Since 1912"
# Meta description
meta_desc <- page %>%
html_element("meta[name='description']") %>%
html_attr("content") %>%
str_squish()
meta_desc
## [1] "Enjoy Free Shipping with $75 purchase on clothing, shoes, outdoor gear and more, all made for the shared joy of the outdoors."
# H1 tags
h1_tags <- page %>%
html_elements("h1") %>%
html_text2() %>%
str_squish() %>%
str_c(collapse = " | ")
h1_tags
## [1] "L.L.Bean - Outside Together Since 1912. Free Shipping with $75 purchase."
# H2 tags
h2_tags <- page %>%
html_elements("h2") %>%
html_text2() %>%
str_squish() %>%
str_c(collapse = " | ")
h2_tags
## [1] "It's time to upgrade your browser | Best Worn to Make Summer Memories | Best Worn to Make Summer Memories"
# H3 tags
h3_tags <- page %>%
html_elements("h3") %>%
html_text2() %>%
str_squish() %>%
str_c(collapse = " | ")
h3_tags
## [1] ""