library(pacman)
p_load(rvest, robotstxt)
paths_allowed("https://en.wikipedia.org/wiki/2024_in_film")
## en.wikipedia.org
## [1] TRUE
#Assignment 3, Q6
wiki_page <- read_html("https://en.wikipedia.org/wiki/2024_in_film")
table_data <- wiki_page %>%
html_elements("table") %>%
.[[3]] %>%
html_table()
all_wikitables <- wiki_page %>%
html_elements(".wikitable")
highest_grossing_table <- all_wikitables[[1]]
table_data <- highest_grossing_table %>%
html_table()
print(head(table_data))
## # A tibble: 6 × 4
## Rank Title Distributor `Worldwide gross`
## <int> <chr> <chr> <chr>
## 1 1 Inside Out 2 Disney $1,698,863,816
## 2 2 Deadpool & Wolverine Disney $1,338,073,645
## 3 3 Moana 2 Disney $1,059,242,164
## 4 4 Despicable Me 4 Universal $971,315,095
## 5 5 Wicked Universal $756,535,681
## 6 6 Mufasa: The Lion King Disney $723,060,982