Rotten Tomatoes Audience Scores

January 22, 2013

I like to use to figure out what movies to watch. The Top Rentals is a good source to start with. It lists the rank and the critics rating for the top 50 movies. The only problem is, sometimes the critics' ratings will be far off from the audience's rating. You have to go to the movie's page to find out the audience's rating. I made a Python script that finds all the audience ratings of the top rentals to help find a movie to watch.

Let's start with the import statements.

In order to speed things up, we will keep a local database of movies we have already found the audience score. The database will also keep track of movies you have watched and will be excluded when you list the movies. It will also keep track of when the movie was first seen in the top 50 and if it is currently in the top 50. We will check if the table rotten exists, if not create it. We will then clear the previous top 50 list.

Next, we will use urllib2 to open the top 50 page. We will use Beautiful Soup to parse the table. We will use the find function to find all the links for the movies in the top 50.

We then check each movie to see if it is in the database. If it isn't we add it to list of pages to visit. If it is, we mark it as a top 50 moive.

Next we visit all the pages of movies that aren't in the database. We use the same procedure as before. The moive name is found in a span with itemprop "name". The critic score is found in a span with id "all-critics-meter".

The audience rating depends on the score of the movie. If it is above 50%, it is found in span with a class "meter popcorn numeric ". If it is less than 50%, it is found in a span with a class "meter spilled numeric ". If it hasn't been reviewed, it is found in a span with a class "meter wts numeric "

Next we list all the movies that are in the top 50 and have not been seen. We sort the list by the audeince score, because that was the whole point of the exercise. We finally commit all the changes to the database.

After we run the script, we see the list of current movies.

To mark a movie as seen, we can use SQLite Manager for Firefox. We can also see movies that aren't in the top 50 anymore that migh have been overlooked.

Download entire script...