#install.packages("pacman")
#install.packages("tidyverse")
#install.packages("rvest")
#install.packages("robotstxt")
pacman::p_load("robotstxt", rvest)
library(robotstxt)
library(rvest)

Question 5 - prescraping data check

paths_allowed("https://en.wikipedia.org/wiki/2026_in_film")
##  en.wikipedia.org
## [1] TRUE

Question 6 - Read Page and create table

film_html <- read_html("https://en.wikipedia.org/wiki/2026_in_film")
length(film_html)
## [1] 2
hg_table_html <- html_element(film_html,"table.wikitable.sortable")

#Convert table to frame
hg_2026 <- html_table(hg_table_html, fill = TRUE)

hg_2026
## # A tibble: 10 × 4
##     Rank Title                             Distributor         `Worldwide gross`
##    <int> <chr>                             <chr>               <chr>            
##  1     1 Cheburashka 2 †                   Central Partnership $79,559,272      
##  2     2 28 Years Later: The Bone Temple † Sony                $56,794,677      
##  3     3 Send Help †                       20th Century Studi… $55,900,522      
##  4     4 Border 2 †                        AA Films            $51,204,000[3]   
##  5     5 Mercy †                           Amazon MGM Studios… $49,994,297      
##  6     6 Iron Lung †                       Markiplier Studios  $42,434,920      
##  7     7 Return to Silent Hill †           Iconic Events Rele… $41,586,056[4]   
##  8     8 Primate †                         Paramount Pictures  $39,722,402      
##  9     9 Dracula †                         SND (France)        $33,618,925      
## 10    10 Mana Shankara Vara Prasad Garu †  Gold Box Entertain… $32,225,000[5][6]