Exemplo n.º 1
0
from task1_imdb import scrape_top_list
from task4_imbd import movie_detail_scrap
from task5_imbd import get_movie_list_detail
from bs4 import BeautifulSoup
import requests
import pprint


def analyse_movies_director(movie_detail):
    dic = {}
    # pprint.pprint(movie_detail_list)
    for i in movie_detail:
        for lan in i["director"]:
            print(lan)
            if lan not in dic:
                dic[lan] = 1
            else:
                dic[lan] += 1
    print(dic)


top_movies = scrape_top_list()
movies_detail = get_movie_list_detail(
    top_movies[:10]
)  #  dekho kaise humne slicing ka use karke humne sirf pehli 10 movies input di. Yeh karna yaad rakhna :)
director_analysis = analyse_movies_director(
    movies_detail
)  # dekho kaise get_movie_list_details ki return value humne analyse_movies_language function mein de di
print(director_analysis)
Exemplo n.º 2
0
from task1_imdb import scrape_top_list
import pprint
whole_data = scrape_top_list()


def group_by_decade(data_collection):
    #movie decade
    movie_decade = {}
    list_year = []
    for i in data_collection:
        modulus = i["year"] % 10
        decade = i["year"] - modulus
        if decade not in list_year:
            list_year.append(decade)
        list_year.sort()
        for k in list_year:
            movie_decade[k] = []
        for j in movie_decade:
            dec10 = j + 9
            for y in data_collection:
                m = y["year"]
                if m <= dec10 and m >= j:
                    movie_decade[j].append(y)

    return movie_decade


movie_decade_year = group_by_decade(whole_data)
pprint.pprint(movie_decade_year)