0

the script that I have here finds the rating of a movie from parsed HTML. What if I wanted to say find a top 50 list by genre and get the output in JSON format (movie: rating), how do I get this info in python? use API or some other method?

import requests
from bs4 import BeautifulSoup 

URL = "google.com/search?q={}"

def find_rating(name):
    ratings = {}
    r = requests.get(URL.format(name))
    s = BeautifulSoup(r.text, "html.parser")
    n = s.find_all("div", class_ = "sDYTm")
    for i in n:
        d = i.text.split(".")
        ratings[d[1]] = d[0]
    return ratings

if __name__ == "__main__":
    movie ="Good WIll Hunting"
    rating = find_rating(movie)
    print(rating)

0 Answers0