How to scrape Rotten Tomatoes website using an easy interface.
Project description
Rotten Tomatoes Scraper
You can extract information about movies and actors that are listed on the Rotten Tomatoes website using this module. Each movie has different metadata such as Rating, Genre, Box Office, Studio, and Scores. The Genre has 20+ subcategories that also gives you more granular information on a movie. These metadata can be helpful for many data science projects. For actors you can extract movies listed in highest-rated or filmography sections depending on your need. This module uses the BeautifulSoup package to parse HTML documents.
Install
The module requires the following libraries:
- bs4
- requests
- lxml
Then, it can be installed using pip:
pip3 install rotten_tomatoes_scraper
Usage
This module contains two classes: MovieScraper and CelebrityScraper.
You can use CelebrityScraper to extract the complete list of movies that a celebrity participated by calling
extract_metadata
method and using section='filmography'
. Plus, you can also extract the list of top ranked movies
by using the same method and section='highest'
.
from rotten_tomatoes_scraper.rt_scraper import CelebrityScraper
celebrity_scraper = CelebrityScraper(celebrity_name='jack nicholson')
celebrity_scraper.extract_metadata(section='highest')
movie_titles = celebrity_scraper.metadata['movie_titles']
print(movie_titles)
['Kubrick by Kubrick (Kubrick par Kubrick)', 'On a Clear Day You Can See Forever', 'The Shooting']
You can also use MovieScraper to extract metadata of movies. If you want to find out what movie genres an actor has
participated, you can, first, extract the list of movies that he or she participated using CelebrityScraper
. Then, you
must instantiate the MovieScraper
and feed the movie_title
to the extract_metada
method. You can feed movie_url
or movie_title
to extract the movie metadata. You can see the code below.
from rotten_tomatoes_scraper.rt_scraper import MovieScraper
movie_scraper = MovieScraper(movie_title='VICKY CRISTINA BARCELONA')
movie_scraper.extract_metadata()
print(movie_scraper.metadata)
{'Score_Rotten': '81%', 'Score_Audience': '74%', 'Rating': 'PG-13', 'Genre': ['Comedy', 'Drama', 'Romance'], 'Box Office': 23164041, 'Studio': 'The Weinstein Co.'}
from rotten_tomatoes_scraper.rt_scraper import MovieScraper
movie_url = 'https://www.rottentomatoes.com/m/marriage_story_2019'
movie_scraper = MovieScraper(movie_url=movie_url)
movie_scraper.extract_metadata()
print(movie_scraper.metadata)
{'Score_Rotten': '94%', 'Score_Audience': '85%', 'Rating': 'R', 'Genre': ['Drama'], 'Studio': 'Netflix'}
This module doesn't give you a full access to all the metadata that you may find in Rotten Tomatoes website. However, you can easily use it to extract the most important ones.
And, that's pretty much it!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for rotten_tomatoes_scraper-1.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fe714c77feb178099456b664c6de998703d5974df52a5bab178779effe91548 |
|
MD5 | 0269e9f7e340325a8021b6f156529bce |
|
BLAKE2b-256 | dc2eab1c53d5566a08309c0283fb45d5491b0a94edb5ce99adf4bee6e4a1ef6d |
Hashes for rotten_tomatoes_scraper-1.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86aa8b9c95c8f727303eb9e424a193a38e94d44f5d49f4bf1a7af2eb0b774fc7 |
|
MD5 | 970922a230b40e0c423fc18ff145260f |
|
BLAKE2b-256 | 97cf0c718dab36c48fd23528271010a58b0b5ed8516465645e735a3cdbae1b06 |