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
hg_films <- data.frame()

for (yr in 2020:2025) {
  url <- paste0("https://en.wikipedia.org/wiki/", yr, "_in_film")
  
  tbl <- session(url, httr::user_agent("Mozilla/5.0")) |>
    read_html() |>
    html_element("table.wikitable") |>
    html_table()
  
  tbl$Rank <- as.character(tbl$Rank)
  tbl$Year <- yr
  hg_films <- bind_rows(hg_films, tbl)
}

hg_films
##    Rank                                                       Title
## 1     1                  Demon Slayer: Kimetsu no Yaiba Mugen Train
## 2     2                                           The Eight Hundred
## 3     3                                      My People, My Homeland
## 4     4                                           Bad Boys for Life
## 5     5                                                       Tenet
## 6     6                                          Sonic the Hedgehog
## 7     7                                                    Dolittle
## 8     8                                                  Jiang Ziya
## 9     9                                         A Little Red Flower
## 10   10                                                Shock Wave 2
## 11    1                                     Spider-Man: No Way Home
## 12    2                                 The Battle at Lake Changjin
## 13    3                                                     Hi, Mom
## 14    4                                              No Time to Die
## 15    5                                                          F9
## 16    6                                       Detective Chinatown 3
## 17    7                                 Venom: Let There Be Carnage
## 18    8                                           Godzilla vs. Kong
## 19    9                   Shang-Chi and the Legend of the Ten Rings
## 20   10                                                        Dune
## 21    1                                    Avatar: The Way of Water
## 22    2                                           Top Gun: Maverick
## 23    3                                     Jurassic World Dominion
## 24    4                 Doctor Strange in the Multiverse of Madness
## 25    5                                    Minions: The Rise of Gru
## 26    6                              Black Panther: Wakanda Forever
## 27    7                                                  The Batman
## 28    8                                      Thor: Love and Thunder
## 29    9                              The Battle at Lake Changjin II
## 30   10                                Puss in Boots: The Last Wish
## 31    1                                                      Barbie
## 32    2                                 The Super Mario Bros. Movie
## 33    3                                                 Oppenheimer
## 34    4                              Guardians of the Galaxy Vol. 3
## 35    5                                                      Fast X
## 36    6                         Spider-Man: Across the Spider-Verse
## 37    7                                              Full River Red
## 38    8                                                       Wonka
## 39    9                                       The Wandering Earth 2
## 40   10               Mission: Impossible – Dead Reckoning Part One
## 41    1                                                Inside Out 2
## 42    2                                        Deadpool & Wolverine
## 43    3                                                     Moana 2
## 44    4                                             Despicable Me 4
## 45    5                                                      Wicked
## 46    6                                       Mufasa: The Lion King
## 47    7                                              Dune: Part Two
## 48    8                             Godzilla x Kong: The New Empire
## 49    9                                             Kung Fu Panda 4
## 50   10                                        Sonic the Hedgehog 3
## 51    1                                                    Ne Zha 2
## 52    2                                                  Zootopia 2
## 53    3                                        Avatar: Fire and Ash
## 54    4                                               Lilo & Stitch
## 55    5                                           A Minecraft Movie
## 56    6                                      Jurassic World Rebirth
## 57    7 Demon Slayer: Kimetsu no Yaiba – The Movie: Infinity Castle
## 58    8                                    How to Train Your Dragon
## 59    9                                                          F1
## 60   10                                                    Superman
##                     Distributor      Worldwide gross Year
## 1                Toho / Aniplex      $507,127,293[4] 2020
## 2                  CMC Pictures         $461,421,559 2020
## 3                    China Lion      $433,241,288[5] 2020
## 4                          Sony         $426,505,244 2020
## 5                  Warner Bros.         $365,309,519 2020
## 6                     Paramount         $319,715,683 2020
## 7                     Universal         $251,410,631 2020
## 8               Beijing Enlight         $243,883,429 2020
## 9              HG Entertainment   $238,600,000[6][7] 2020
## 10               Universe Films         $226,400,000 2020
## 11                         Sony $1,921,426,073[nb 1] 2021
## 12                         Bona         $909,596,236 2021
## 13                     Lian Ray         $841,674,419 2021
## 14              MGM / Universal         $774,253,007 2021
## 15                    Universal         $726,229,501 2021
## 16         Warner Bros. / Wanda         $686,257,563 2021
## 17                         Sony         $506,863,592 2021
## 18          Warner Bros. / Toho         $470,116,094 2021
## 19                       Disney         $432,243,292 2021
## 20                 Warner Bros.         $411,000,000 2021
## 21                 20th Century $2,320,250,281[nb 1] 2022
## 22                    Paramount $1,495,696,292[nb 1] 2022
## 23                    Universal       $1,001,978,080 2022
## 24                       Disney         $955,775,804 2022
## 25                    Universal         $940,628,210 2022
## 26                       Disney         $859,208,836 2022
## 27                 Warner Bros.         $772,245,583 2022
## 28                       Disney         $760,928,081 2022
## 29                         Bona         $626,571,697 2022
## 30                    Universal         $485,261,639 2022
## 31                 Warner Bros.       $1,448,232,531 2023
## 32                    Universal       $1,360,847,665 2023
## 33                    Universal         $975,811,333 2023
## 34                       Disney         $845,555,777 2023
## 35                    Universal         $714,875,015 2023
## 36                         Sony         $690,824,738 2023
## 37             China Film Group         $670,491,959 2023
## 38                 Warner Bros.         $634,681,815 2023
## 39             China Film Group         $615,023,132 2023
## 40                    Paramount         $571,125,435 2023
## 41                       Disney       $1,698,863,816 2024
## 42                       Disney       $1,338,073,645 2024
## 43                       Disney       $1,059,242,164 2024
## 44                    Universal         $972,021,410 2024
## 45                    Universal         $758,729,195 2024
## 46                       Disney         $723,060,982 2024
## 47                 Warner Bros.         $715,409,065 2024
## 48                 Warner Bros.         $572,505,338 2024
## 49                    Universal         $547,689,492 2024
## 50                    Paramount         $492,162,604 2024
## 51              Beijing Enlight $2,215,690,000[3][4] 2025
## 52                       Disney       $1,870,309,291 2025
## 53                 20th Century       $1,490,386,712 2025
## 54                       Disney       $1,038,027,526 2025
## 55                 Warner Bros.         $961,287,780 2025
## 56                    Universal         $872,428,220 2025
## 57 Aniplex / Toho / Crunchyroll         $793,594,078 2025
## 58                    Universal         $639,866,451 2025
## 59         Warner Bros. / Apple         $634,142,436 2025
## 60                 Warner Bros.         $618,723,803 2025