from __future__ import annotations

import csv

import requests
from bsa import BeautifulSoup







def 			__UpperCamelCase     (    A = ""				):
     UpperCamelCase__					    =   url or '''https://www.imdb.com/chart/top/?ref_=nv_mv_250'''
     UpperCamelCase__					    =   BeautifulSoup(requests.get(__snake_case				).text			,				'''html.parser'''				)
     UpperCamelCase__					    =   soup.find_all('''td'''			,				attrs='''titleColumn'''				)
     UpperCamelCase__					    =   soup.find_all('''td'''			,				class_='''ratingColumn imdbRating'''				)
     return {
         title.a.text: float(rating.strong.text				)
         for title, rating in zip(__snake_case			,				__snake_case				)
     }







def 			__UpperCamelCase     (    A = "IMDb_Top_250_Movies.csv"				):
     UpperCamelCase__					    =   get_imdb_top_aaa_movies()
     with open(__snake_case			,				'''w'''			,				newline=''''''				) as out_file:
          UpperCamelCase__					    =   csv.writer(__snake_case				)
          writer.writerow(['''Movie title''', '''IMDb rating''']				)
          for title, rating in movies.items():
               writer.writerow([title, rating]				)


if __name__ == "__main__":
     write_movies()











import os

# Precomputes a list of the 100 first triangular numbers
lowerCamelCase      :       str    =						[int(0.5 * n * (n + 1)) for n in range(1, 101)]





def    __lowerCAmelCase   (    ):
     __lowerCAmelCase             =       os.path.dirname(os.path.realpath(__snake_case							)							)
     __lowerCAmelCase             =       os.path.join(__snake_case       ,			"words.txt"							)

     __lowerCAmelCase             =       ""
     with open(__snake_case							) as f:
          __lowerCAmelCase             =       f.readline()

     __lowerCAmelCase             =       [word.strip("\""							) for word in words.strip("\r\n"							).split(","							)]
     __lowerCAmelCase             =       [
         word
         for word in [sum(ord(__snake_case							) - 64 for x in word							) for word in words]
         if word in TRIANGULAR_NUMBERS
     ]
     return len(__snake_case							)


if __name__ == "__main__":
 print(solution())






