Question 5

pacman::p_load(robotstxt, rvest)
paths_allowed("https://www.imdb.com/title/tt7235466/fullcredits?ref_=tt_cl_sm")
##  www.imdb.com
## [1] TRUE

Question 6

imdb_html <- read_html("https://www.imdb.com/title/tt7235466/fullcredits?ref_=tt_cl_sm")
tables <- html_elements(imdb_html, "table")
cast <- html_table(tables[3])
cast_tibble <- cast[[1]]
cast_tibble
## # A tibble: 2,946 × 4
##    X1    X2               X3    X4                                              
##    <lgl> <chr>            <chr> <chr>                                           
##  1 NA    ""               ""    ""                                              
##  2 NA    "Angela Bassett" "..." "Athena Grant\n         / ...  \n              …
##  3 NA    ""               ""    ""                                              
##  4 NA    "Peter Krause"   "..." "Bobby Nash\n                  107 episodes, 20…
##  5 NA    ""               ""    ""                                              
##  6 NA    "Oliver Stark"   "..." "Evan 'Buck' Buckley\n         / ...  \n       …
##  7 NA    ""               ""    ""                                              
##  8 NA    "Aisha Hinds"    "..." "Henrietta 'Hen' Wilson\n         / ...  \n    …
##  9 NA    ""               ""    ""                                              
## 10 NA    "Kenneth Choi"   "..." "Howie 'Chimney' Han\n         / ...  \n       …
## # ℹ 2,936 more rows

Question 7

cast_tibble[c(2, 4)]
## # A tibble: 2,946 × 2
##    X2               X4                                                          
##    <chr>            <chr>                                                       
##  1 ""               ""                                                          
##  2 "Angela Bassett" "Athena Grant\n         / ...  \n                  107 epis…
##  3 ""               ""                                                          
##  4 "Peter Krause"   "Bobby Nash\n                  107 episodes, 2018-2024"     
##  5 ""               ""                                                          
##  6 "Oliver Stark"   "Evan 'Buck' Buckley\n         / ...  \n                  1…
##  7 ""               ""                                                          
##  8 "Aisha Hinds"    "Henrietta 'Hen' Wilson\n         / ...  \n                …
##  9 ""               ""                                                          
## 10 "Kenneth Choi"   "Howie 'Chimney' Han\n         / ...  \n                  1…
## # ℹ 2,936 more rows
essential_cast <- cast_tibble[seq(2, nrow(cast_tibble), 2),]
print(essential_cast)
## # A tibble: 1,473 × 4
##    X1    X2                   X3    X4                                          
##    <lgl> <chr>                <chr> <chr>                                       
##  1 NA    Angela Bassett       ...   "Athena Grant\n         / ...  \n          …
##  2 NA    Peter Krause         ...   "Bobby Nash\n                  107 episodes…
##  3 NA    Oliver Stark         ...   "Evan 'Buck' Buckley\n         / ...  \n   …
##  4 NA    Aisha Hinds          ...   "Henrietta 'Hen' Wilson\n         / ...  \n…
##  5 NA    Kenneth Choi         ...   "Howie 'Chimney' Han\n         / ...  \n   …
##  6 NA    Jennifer Love Hewitt ...   "Maddie Kendall\n         / ...  \n        …
##  7 NA    Ryan Guzman          ...   "Eddie Diaz\n                  97 episodes,…
##  8 NA    Corinne Massiah      ...   "May Grant\n                  93 episodes, …
##  9 NA    Gavin McHugh         ...   "Christopher Diaz\n                  86 epi…
## 10 NA    Marcanthonee Reis    ...   "Harry Grant\n                  74 episodes…
## # ℹ 1,463 more rows

Question 8

colnames(cast_tibble) <- c("v1","v2")
names(cast_tibble) <- c("v1","v2")
## Warning: The `value` argument of `names<-()` must have the same length as `x` as of
## tibble 3.0.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `value` argument of `names<-()` can't be empty as of tibble 3.0.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.