def first(): data = scrape_top_list() for i in data: movie_url = i['url'] cast_link = movie_url + 'fullcredits#cast' linked_Data = link_movie(movie_url, cast_link) total_data_list.append(linked_Data) js = json.dumps(total_data_list, indent=4, sort_keys=True) with open("Total_movie_list_with_casts.json", "w") as q: # Total movies List of 250 movies q.write(js)
## In this task, I have counted all the movies that have been released in Hindi, English and Malayalam languages. from Task5 import get_movie_list_details from Task1 import scrape_top_list movies_list = scrape_top_list() top_ten_movie = movies_list[:250] def analyse_movies_language(how_many_movies): allmovies = get_movie_list_details(how_many_movies) hindi = 0 english = 0 malayalam = 0 for each_movie in allmovies: # print (allmovies) lang_list = each_movie['Language'] for i in lang_list: if i == "Hindi": hindi += 1 elif i == "English": english += 1 elif i == "Malayalam": malayalam+=1 lang_dic = {'Hindi': hindi, 'English': english, 'Malayalam': malayalam} return (lang_dic) print (analyse_movies_language(top_ten_movie))
from Task1 import scrape_top_list import requests import json from bs4 import BeautifulSoup from pprint import pprint name1 = scrape_top_list() year = [] def group_by_decade(): i = 0 while i < len(name1): year.append(name1[i]["year"]) i = i + 1 year.sort() j = 0 my_dict = {} while j < len(year): dec = (year[j] // 10) * 10 k = 0 decade = [] while k < len(name1): if name1[k]["year"] >= dec and name1[k]["year"] < (dec + 10): decade.append(name1[k]) my_dict[dec] = decade k = k + 1 j = j + 1 with open("decade_vise_movie.json", "w") as saral_data3: json.dump(my_dict, saral_data3, indent=4)
def funfirst(): data1 = scrape_top_list() for i in data1: castLink = i['url'] + 'fullcredits#cast' casting(castLink)
time = soup.find("div",class_="subtext") runtime = time.find("time").get_text().strip() hour_in_min = (int(runtime[0])) *60 i = 0 mins = "" b = (runtime[3:]) while i < len(b): if b[i] == "m": break mins = mins + b[i] i = i + 1 runtime_of_movie = hour_in_min + int(mins) movie_genre = time.find_all("a") movie_genre.pop() for i in movie_genre: genre = i.get_text() gen.append(genre) details["movie_name"] = name1["name"] details["director"] = dire details["country"] = "India" details["poster_url"] = movie_poster details["language"] = lang details["movie_bio"] = movie_bio details["runtime"] = runtime_of_movie details["movie_genre"] = gen list1.append(details.copy()) with open("10movies_details.json","w") as movie: json.dump(list1,movie,indent=4) return(list1) top_movie_list = movies_details(scrape_top_list())