Scraping URLs for quick SEO insights

library(rvest)
## Warning: package 'rvest' was built under R version 4.6.1
library(stringr)
## Warning: package 'stringr' was built under R version 4.6.1
library(httr2)
## Warning: package 'httr2' was built under R version 4.6.1
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.6.1
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# List of URLs to scrape
urls <- c(
  "https://hestanculinary.com",
  "https://www.surlatable.com", 
  "https://staubc.com/"
)

# Empty list to collect results
results <- list()

for (i in seq_along(urls)) {
  
  Sys.sleep(1.5) # polite delay between requests
  
  page <- read_html(urls[i])
  
  title_tag <- page %>%
    html_element("title") %>%
    html_text2() %>%
    str_squish()
 title_tag 
 
  meta_desc <- page %>%
    html_element("meta[name='description']") %>%
    html_attr("content") %>%
    str_squish()
 meta_desc
 
  h1_tags <- page %>%
    html_elements("h1") %>%
    html_text2() %>%
    str_squish() %>%
    str_c(collapse = " | ")
h1_tags
  
  h2_tags <- page %>%
    html_elements("h2") %>%
    html_text2() %>%
    str_squish() %>%
    str_c(collapse = " | ")

  h2_tags
    
  h3_tags <- page %>%
    html_elements("h3") %>%
    html_text2() %>%
    str_squish() %>%
    str_c(collapse = " | ")
  
  h3_tags
  
  # Store this page's results as a one-row tibble
  results[[i]] <- tibble(
    url = urls[i],
    title = title_tag,
    meta_description = meta_desc,
    h1 = h1_tags,
    h2 = h2_tags,
    h3 = h3_tags
  )
}

# Combine all rows into one data frame
seo_data <- bind_rows(results)

seo_data
## # A tibble: 3 × 6
##   url                        title            meta_description h1    h2    h3   
##   <chr>                      <chr>            <chr>            <chr> <chr> <chr>
## 1 https://hestanculinary.com Hestan Culinary… Why Hestan Culi… ""    "Pro… "Whe…
## 2 https://www.surlatable.com Sur La table | … Feel inspired t… ""    ""    ""   
## 3 https://staubc.com/        Staub Cookware,… Shop Staub for … "Sta… "The… "Sta…
write.csv(seo_data, file = "seo_data.csv", row.names = FALSE)

seo_data$title
## [1] "Hestan Culinary | Chef-Proven Performance"              
## [2] "Sur La table | Cookware, Dinnerware, Cutlery & Bakeware"
## [3] "Staub Cookware, Dutch Ovens & Bakeware Official Website"
seo_data$meta_description
## [1] "Why Hestan Culinary? Exclusive ProCore™ aluminum delivers 35% faster heat conduction and 20% greater cooking surface area for skillets. Shop today!"             
## [2] "Feel inspired to whip up culinary magic with Sur La Table's vast kitchenware selection. From unique gadgets to expert tips, spark your cooking creativity today."
## [3] "Shop Staub for premium French enameled cast iron cookware. Explore our Dutch ovens, skillets, and bakeware collections on the official website."
seo_data$h1
## [1] ""                                              
## [2] ""                                              
## [3] "Staub Cookware: French Cast Iron, Made to Last"
seo_data$h2
## [1] "Professional Clad Stainless Steel | 10 Days Of Grilling | We've Added To The NanoBond® Collection! | Welcome New Chef's Tools! | Hestan Napa | Backed by Michelin-Level Credibility | Shop 10 Days Of Grilling Favorites | Molecular Titanium | Molecular Titanium | Molecular Titanium | Molecular Titanium | Molecular Titanium | Molecular Titanium | Happy Fourth Of July From Hestan | The Italian Cookware All Chefs Use Want | What collection is right for you? | NanoBond® | CopperBond® | ProBond® Forged | ProBond® Luxe | Thomas Keller Commercial Clad | TITUM® Nonstick | Shop by Category | A New Original. By the Innovators of Premium Italian Cookware | Gift Cards Available | Have Questions? Talk with Michael | See The Latest From The Hestan Kitchen | Hear from some of the world's greatest chefs | Award Winning Cookware | About | Help & Support | Explore | Hestan Brands | Get in touch | Hestan Chef’s Table™ Membership"
## [2] ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
## [3] "The Art of French Cast Iron | Staub Enameled Cast Iron Everything Braiser, 3.5-Qt. Staub - Seller | Newest Staub Cookware Products | Buyer Favorites | Best-Selling Staub Cookware | Staub Enameled Cast Iron Everything Braiser, 3.5-Qt. | $129 | Staub Enameled Cast Iron Double Burner Griddle | $169 | Staub Cookware Values | Why Staub Stands Apart | 4.7 stars from real Staub owners | Care, Use, and Cleaning"
seo_data$h3
## [1] "When should we send your message?"                               
## [2] ""                                                                
## [3] "Staub | Braisers & Skillets | Highlights | What to watch | Staub"

Findings Analysis

The SEO scrape shows that the high end cookware brands, Hestan Culinary, Sur La Table, and Staub all use clear title tags and meta descriptions that communicate their brand focus. Hestan emphasizes their high tech solutions, Sur La Table emphasizes their broad selection, and Staub focuses on their French cast iron cookware provenance.

Hestan has the most extensive SEO implementation in this scrape because its tags include a wide variety of topics like, promotions, credibility, cookware categories, and customer support, which gives the page in depth SEO.Staub also has strong SEO since includes clear tags related to their cast iron cookware and product categories. Sur La Table has useful title and meta description content but appears weaker overall because no headings were available to the scrape.

Overall, I would assert that Hestan is the most optimized for search engine appearances, but I had not heard of this brand until this exercise. Additional positioning in related blogs would strengthen their overall position.