I'm trying to write a program for my friends and I to keep track of the movies we have watched and keep a list of movies that we wanted to watch.

What I'm trying to do is write a program in Python that takes a movie title and adds that movie to a list in excel, then searches google for information about that movie from various sources and adds that into the excel document (For example if I type in "Back to the Future" into Python it adds that into the first column in my excel document then searches google for ratings for Back to the Future and grabs them from IMDB, Rotten Tomatoes and Metacritic from the box that google displays on the side of the search with all the movie info.)

I have written the code for Inputting the Movie Title into excel, but am completely lost on where to start for grabbing the movie ratings from google, any help would be greatly appreciated.

UPDATE: Was able to figure it out, here is the working code if anyone is interested:

import openpyxl
from imdb import IMDb
from omdbapi.movie_search import GetMovie

wb = openpyxl.load_workbook('MovieList.xlsx')
ws = wb.active

ia = IMDb()

while True:
    userinput = input('Please enter a movie title: ')
    if(userinput == 'end it'):
    s_result = ia.search_movie(userinput)
    movie = s_result[0]
    maxrow = ws.max_row +1
    ws.cell(column=1, row=maxrow, value=movie['long imdb canonical title'])

    genre = ", ".join(movie['genre'])

    movie = GetMovie(title=userinput, api_key='API')
    OMDBRATINGS = movie.get_data('Ratings', 'Runtime')
    #info = OMDBRATINGS.values()

    ws.cell(column=2, row=maxrow, value=genre)
    ws.cell(column = 3, row = maxrow, value = OMDBRATINGS['Ratings'][0]['Value'])
    ws.cell(column=5, row=maxrow, value=OMDBRATINGS['Ratings'][1]['Value'])
    ws.cell(column=4, row=maxrow, value=OMDBRATINGS['Ratings'][2]['Value'])
    ws.cell(column=6, row=maxrow, value=OMDBRATINGS['Runtime'])


1 Answers

Community On

First of all, I would advise against scraping anything from google (or any search platform for that matter). This will most likely get your IP blacklisted (see another stackoverflow post (is-it-ok-to-scrape-data-from-google-results). If you're inclined to move forward you should consider duckduckgo.com as an alternative.

That being said, I would try the OMDB Api first using the requests python library. They have a pretty thorough database of movie titles that might satisfy your requirements.