library(tidyverse)
library(rvest)
library(httr2)
library(kableExtra)

Project Overview

This project compares the basic SEO elements of music related websites. The goal is to scrape each site’s title tag, meta description, and H1/H2/H3 headings, then compare which site gives search engines and users clearer information.

sites <- tibble(
  company = c("Spotify", "Sweetwater", "Guitar Center", "Bandcamp", "Reverb", "Ultimate-Guita"),
  url = c(
    "https://www.spotify.com",
    "https://www.sweetwater.com",
    "https://www.guitarcenter.com",
    "https://bandcamp.com",
    "https://www.reverb.com",
    "https://www.ultimate-guitar.com"
  )
)
scrape_seo_elements <- function(url, company_name) {
  
  Sys.sleep(1.5)
  
  tryCatch({
    
    response <- request(url) %>%
      req_headers(
        `User-Agent` = "Mozilla/5.0 (compatible; MSBA580-SEO-Project/1.0)"
      ) %>%
      req_timeout(15) %>%
      req_perform()
    
    page <- response %>%
      resp_body_string() %>%
      read_html()
    
    title_tag <- page %>%
      html_element("title") %>%
      html_text2() %>%
      str_squish()
    
    meta_desc <- page %>%
      html_element("meta[name='description']") %>%
      html_attr("content") %>%
      str_squish()
    
    h1_headings <- page %>%
      html_elements("h1") %>%
      html_text2() %>%
      str_squish() %>%
      paste(collapse = " | ")
    
    h2_headings <- page %>%
      html_elements("h2") %>%
      html_text2() %>%
      str_squish() %>%
      paste(collapse = " | ")
    
    h3_headings <- page %>%
      html_elements("h3") %>%
      html_text2() %>%
      str_squish() %>%
      paste(collapse = " | ")
    
    tibble(
      company = company_name,
      url = url,
      title = ifelse(length(title_tag) == 0, NA, title_tag),
      meta_desc = ifelse(length(meta_desc) == 0, NA, meta_desc),
      h1 = ifelse(h1_headings == "", NA, h1_headings),
      h2 = ifelse(h2_headings == "", NA, h2_headings),
      h3 = ifelse(h3_headings == "", NA, h3_headings)
    )
    
  }, error = function(e) {
    
    tibble(
      company = company_name,
      url = url,
      title = NA,
      meta_desc = NA,
      h1 = NA,
      h2 = NA,
      h3 = NA
    )
  })
}
seo_data <- map2_dfr(
  sites$url,
  sites$company,
  ~ scrape_seo_elements(url = .x, company_name = .y)
)

seo_data
## # A tibble: 6 × 7
##   company        url                           title meta_desc h1    h2    h3   
##   <chr>          <chr>                         <chr> <chr>     <chr> <chr> <chr>
## 1 Spotify        https://www.spotify.com       Spot… Spotify … <NA>  Tren… <NA> 
## 2 Sweetwater     https://www.sweetwater.com    Swee… Sweetwat… Find… Welc… Guit…
## 3 Guitar Center  https://www.guitarcenter.com  <NA>  <NA>      <NA>  <NA>  <NA> 
## 4 Bandcamp       https://bandcamp.com          Band… Discover… Fans… Band… <NA> 
## 5 Reverb         https://www.reverb.com        <NA>  <NA>      <NA>  <NA>  <NA> 
## 6 Ultimate-Guita https://www.ultimate-guitar.… <NA>  <NA>      <NA>  <NA>  <NA>
seo_data %>%
  kbl(caption = "SEO Elements: Music") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
SEO Elements: Music
company url title meta_desc h1 h2 h3
Spotify https://www.spotify.com Spotify - Web Player: Music for everyone Spotify is a digital music service that gives you access to millions of songs. NA Trending songs | Popular artists | Popular albums and singles | Popular radio | Featured Charts NA
Sweetwater https://www.sweetwater.com Sweetwater: Musical Instruments, Pro Audio, Accessories & More Sweetwater is the world’s leading music technology and instrument retailer, offering ✓ Highly Knowledgeable Sales Engineers, ✓ In-house Technical Support… Find Your Next Musical Instrument at Sweetwater Welcome! | Popular Categories | Get More at Sweetwater | Top New Musical Instruments & Gear | Plenty of Ways To Score Great Gear | Your Research Destination | You shop here, why not work here? Guitars | Studio & Recording | Drums & Percussion | Bass | Keyboards & Synth | Live Sound & Lights | Software & Plug-ins | DJ Equipment | Microphones & Wireless | Band & Orchestra | Home Audio & Electronics | Commercial Audio & Install | Cables, Cases, Stands & More | Cameras & Video | Line 6 Helix Stadium XL | The Future of Modeling is HERE | Inside Martin Guitar’s Museum & the Four Sweetwater-exclusive Instruments It Inspired | How to Upgrade Your Microphones for Better Worship Sound | Best Closed-back Headphones for DJs in 2026 | Best Portable PA Systems in 2026
Guitar Center https://www.guitarcenter.com NA NA NA NA NA
Bandcamp https://bandcamp.com Bandcamp Discover amazing music and directly support the artists who make it. Fans have paid artists $1.75 billion using Bandcamp, and yesterday alone bought 69,852 records. Bandcamp Daily | Playlists in fan collections | Bandcamp Radio | New and Notable | Album of the Day | Discover music by genre and location | Discover merch | Player NA
Reverb https://www.reverb.com NA NA NA NA NA
Ultimate-Guita https://www.ultimate-guitar.com NA NA NA NA NA
write.csv(seo_data, file = "seo_data.csv", row.names = FALSE)

Findings

SEO results indicated Sweetwater had the most effective setup. It had a proper title, meta description, H1/H2/H3 headings. Bandcamp also had good SEO, with its description and headings very focused on music discovery, artists and merch. Spotify had a good title and description but lacked some headings. Guitar Center, Reverb and Ultimate Guitar had mostly NA values which could mean that the sites blocked scraping or data loaded differently. Overall SEO, Sweetwater was the best of the results scraped.