get imdbtop Algorithm

The get imdbtop Algorithm is a powerful tool that analyzes and extracts information from the Internet Movie Database (IMDb) to provide users with a comprehensive list of the top-rated movies. IMDb is a renowned online database containing a wealth of information about movies, television shows, video games, and other entertainment content, including cast and crew details, synopses, ratings, and user reviews. By leveraging this vast resource, the get imdbtop Algorithm sifts through the data to identify the highest-rated films based on user ratings, offering individuals an efficient means of discovering the best movies to watch. This cutting-edge algorithm works by employing web scraping techniques to gather the relevant data from IMDb's top-rated movies page, which is regularly updated to reflect the latest user ratings. The algorithm then processes and ranks the movies based on specific criteria, such as the number of votes and the overall rating. The result is a curated list of the top films, which can be presented in a user-friendly format, such as a table or chart. The get imdbtop Algorithm is an invaluable resource for movie enthusiasts, critics, and researchers alike, as it provides a reliable and up-to-date reference for the most highly regarded films in the world of cinema.
from bs4 import BeautifulSoup
import requests


def imdb_top(imdb_top_n):
    base_url = (
        f"https://www.imdb.com/search/title?title_type="
        f"feature&sort=num_votes,desc&count={imdb_top_n}"
    )
    source = BeautifulSoup(requests.get(base_url).content, "html.parser")
    for m in source.findAll("div", class_="lister-item mode-advanced"):
        print("\n" + m.h3.a.text)  # movie's name
        print(m.find("span", attrs={"class": "genre"}).text)  # genre
        print(m.strong.text)  # movie's rating
        print(f"https://www.imdb.com{m.a.get('href')}")  # movie's page link
        print("*" * 40)


if __name__ == "__main__":
    imdb_top(input("How many movies would you like to see? "))

LANGUAGE:

DARK MODE: