Question 1

No Code Required

Question 2

No Code Required

Question 3

No Code Required

Question 4

No Code Required

Question 5

# Install if needed
# install.packages("robotstxt")

library(robotstxt)

# Check if the specific Wikipedia page is allowed
paths_allowed("https://en.wikipedia.org/wiki/2026_in_film")
##  en.wikipedia.org
## [1] TRUE

Question 6

# Load libraries
library(rvest)
library(dplyr)
## 
## 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
# Read the webpage
url <- "https://en.wikipedia.org/wiki/2026_in_film"
page <- read_html(url)

# Extract all tables
tables <- page %>% 
  html_elements("table") %>% 
  html_table(fill = TRUE)

# Inspect table names/structure to find the correct one
# (You may need to check tables[[x]] to identify the right table)
tables
## [[1]]
## # A tibble: 3 × 1
##   `List of years in film`                                                       
##   <chr>                                                                         
## 1 "… 2016\n2017\n2018\n2019\n2020\n2021\n2022\n2023\n2024\n2025\n2026\n2027\n20…
## 2 "Art\nArchaeology\nArchitecture\n\nLiterature\nMusic\nPhilosophy\nScience+..."
## 3 ".mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.m…
## 
## [[2]]
## # A tibble: 19 × 1
##    `Years in film`                                                    
##    <chr>                                                              
##  1 ""                                                                 
##  2 "19th century"                                                     
##  3 "1870s"                                                            
##  4 "1880s\n1880\n1881\n1882\n1883\n1884\n1885\n1886\n1887\n1888\n1889"
##  5 "1890s\n1890\n1891\n1892\n1893\n1894\n1895\n1896\n1897\n1898\n1899"
##  6 "1900s\n1900\n1901\n1902\n1903\n1904\n1905\n1906\n1907\n1908\n1909"
##  7 "1910s\n1910\n1911\n1912\n1913\n1914\n1915\n1916\n1917\n1918\n1919"
##  8 "1920s\n1920\n1921\n1922\n1923\n1924\n1925\n1926\n1927\n1928\n1929"
##  9 "1930s\n1930\n1931\n1932\n1933\n1934\n1935\n1936\n1937\n1938\n1939"
## 10 "1940s\n1940\n1941\n1942\n1943\n1944\n1945\n1946\n1947\n1948\n1949"
## 11 "1950s\n1950\n1951\n1952\n1953\n1954\n1955\n1956\n1957\n1958\n1959"
## 12 "1960s\n1960\n1961\n1962\n1963\n1964\n1965\n1966\n1967\n1968\n1969"
## 13 "1970s\n1970\n1971\n1972\n1973\n1974\n1975\n1976\n1977\n1978\n1979"
## 14 "1980s\n1980\n1981\n1982\n1983\n1984\n1985\n1986\n1987\n1988\n1989"
## 15 "1990s\n1990\n1991\n1992\n1993\n1994\n1995\n1996\n1997\n1998\n1999"
## 16 "2000s\n2000\n2001\n2002\n2003\n2004\n2005\n2006\n2007\n2008\n2009"
## 17 "2010s\n2010\n2011\n2012\n2013\n2014\n2015\n2016\n2017\n2018\n2019"
## 18 "2020s\n2020\n2021\n2022\n2023\n2024\n2025\n2026\n…"               
## 19 "vte"                                                              
## 
## [[3]]
## # 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]
## 
## [[4]]
## # A tibble: 19 × 5
##    Date        Event                                  Host   `Location(s)` Ref. 
##    <chr>       <chr>                                  <chr>  <chr>         <chr>
##  1 January 4   31st Critics' Choice Awards            Criti… "California,… "[ci…
##  2 January 11  83rd Golden Globe Awards               Golde… "Beverly Hil… ""   
##  3 January 17  38th European Film Awards              Europ… "Berlin, Ger… "[7]"
##  4 January 18  31st Lumière Awards                    Acadé… "Paris, Fran… "[8]"
##  5 January 24  13th Feroz Awards                      Asoci… "Pontevedra,… "[9]"
##  6 January 31  5th Carmen Awards                      Acade… "Granada, An… "[10…
##  7 February 7  78th Directors Guild of America Awards Direc… "Beverly Hil… ""   
##  8 February 8  18th Gaudí Awards                      Catal… "Barcelona, … "[11…
##  9 February 21 53rd Annie Awards                      ASIFA… "Los Angeles… "[12…
## 10 February 22 79th British Academy Film Awards       Briti… "London, UK"  ""   
## 11 February 26 51st César Awards                      Acadé… "Paris, Fran… "[13…
## 12 February 28 37th Producers Guild of America Awards Produ… "Los Angeles… ""   
## 13 February 28 40th Goya Awards                       Acade… "Barcelona, … "[14…
## 14 March 1     32nd Actor Awards                      SAG-A… "Los Angeles… "[ci…
## 15 March 8     53rd Saturn Awards                     Acade… "Universal C… "[15…
## 16 March 8     78th Writers Guild of America Awards   Write… ""            ""   
## 17 March 14    46th Golden Raspberry Awards           Golde… "Los Angeles… ""   
## 18 March 15    98th Academy Awards                    Acade… "Los Angeles… "[16…
## 19 March 16    34th Actors and Actresses Union Awards Actor… "Madrid, Spa… "[17…
## 
## [[5]]
## # A tibble: 9 × 5
##   Date                    Event                        Host  `Location(s)` Ref. 
##   <chr>                   <chr>                        <chr> <chr>         <chr>
## 1 January 2 – 12          37th Palm Springs Internati… Palm… Palm Springs… "[18…
## 2 January 22 – February 1 2026 Sundance Film Festival  Sund… Park City, U… "[19…
## 3 January 29 – February 8 55th International Film Fes… Inte… Rotterdam, N… "[20…
## 4 February 4 – 14         41st Santa Barbara Internat… Sant… Santa Barbar… "[21…
## 5 February 12 – 22        76th Berlin International F… Berl… Berlin, Germ… "[22…
## 6 February 25 – March 8   22nd Glasgow Film Festival   Glas… Glasgow, Uni… "[23…
## 7 March 6 – 15            29th Málaga Film Festival    Mála… Málaga, Spain "[24…
## 8 May 12 – 23             2026 Cannes Film Festival    Cann… Cannes, Fran… ""   
## 9 August 13 – 19          79th Edinburgh Internationa… Edin… Edinburgh, U… "[25…
## 
## [[6]]
## # A tibble: 43 × 8
##    Month    Date Name                  Age Country    Profession `Notable films`
##    <chr>   <int> <chr>               <int> <chr>      <chr>      <chr>          
##  1 January     1 Arno Liiver            71 Estonia    Actor      SpringSummer   
##  2 January     2 Con Pederson           91 US         Visual Ef… 2001: A Space …
##  3 January     4 Sverre Anker Ousdal    81 Norway     Actor      Flight of the …
##  4 January     5 Ahn Sung-ki            74 South Kor… Actor      Two CopsHansan…
##  5 January     6 John Cunningham        93 US         Actor      Mystic PizzaDe…
##  6 January     6 Saeid Pirdoost         85 Iran       Actor      The DeerKillin…
##  7 January     6 Béla Tarr              70 Hungary    Director,… SátántangóThe …
##  8 January     8 Guy Moon               63 US         Composer   The Brady Bunc…
##  9 January     9 T. K. Carter           69 US         Actor      The ThingSpace…
## 10 January     9 Nessa Hyams            84 US         Casting D… The ExorcistBl…
## # ℹ 33 more rows
## # ℹ 1 more variable:
## #   `.mw-parser-output .tooltip-dotted{border-bottom:1px dotted;cursor:help}Ref.` <chr>
## 
## [[7]]
## # A tibble: 1 × 2
##   X1    X2                                                                    
##   <lgl> <chr>                                                                 
## 1 NA    This section is empty.  You can help by adding to it.  (February 2026)
# For example, if the "Highest-grossing films" table is the 2nd table:
highest_grossing <- tables[[3]]

# View the structured data
highest_grossing
## # 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]

Question 7

No Code Required

Question 8

library(rvest)
library(dplyr)
library(purrr)
library(stringr)

years <- 2020:2025

get_hg_films <- function(year) {
  
  url <- paste0("https://en.wikipedia.org/wiki/", year, "_in_film")
  page <- read_html(url)
  
  # Get all tables
  tables <- page %>%
    html_elements("table") %>%
    html_table(fill = TRUE)
  
  # Keep the table that contains "Highest-grossing"
  hg_table <- tables %>%
    keep(~ any(str_detect(names(.), "Gross|Film|Title")))
  
  # Usually the first match is correct
  hg_table[[1]] %>%
    mutate(year = year)
}

hg_films <- map_dfr(years, get_hg_films)

hg_films
## # A tibble: 60 × 5
##     Rank Title                               Distributor `Worldwide gross`  year
##    <int> <chr>                               <chr>       <chr>             <int>
##  1     1 Demon Slayer: Kimetsu no Yaiba Mug… Toho / Ani… $507,127,293[4]    2020
##  2     2 The Eight Hundred                   CMC Pictur… $461,421,559       2020
##  3     3 My People, My Homeland              China Lion  $433,241,288[5]    2020
##  4     4 Bad Boys for Life                   Sony        $426,505,244       2020
##  5     5 Tenet                               Warner Bro… $365,309,519       2020
##  6     6 Sonic the Hedgehog                  Paramount   $319,715,683       2020
##  7     7 Dolittle                            Universal   $251,410,631       2020
##  8     8 Jiang Ziya                          Beijing En… $243,883,429       2020
##  9     9 A Little Red Flower                 HG Enterta… $238,600,000[6][…  2020
## 10    10 Shock Wave 2                        Universe F… $226,400,000       2020
## # ℹ 50 more rows