Automated Posting of Rotten Tomatoes Data on X (Twitter): A How-To Guide

Shoeb Ahmed
CodeX
Published in
3 min readMay 6, 2024

Hello, I’m here to share an idea on automating Twitter content posting using Python and web scraping. Learn how to streamline your Twitter updates effortlessly!

Why I am using Rotten Tomatoes?

Rotten Tomatoes is a popular website that aggregates reviews from critics and provides a rating based on the percentage of positive reviews. It’s a trusted source for movie and TV show ratings.

My main objective is to create a pipeline that will automatically post the data on X, not only based on data from Rotten Tomatoes. It should be compatible with any platform.

I am going to share a block diagram as shown below:

Generic block diagram

I followed these steps:

1. Visited the Rotten Tomatoes website.
2. Selected the category, i.e., Upcoming movies.
3. Used Python requests to extract data using GET methods.
4. Used BeautifulSoup to extract the required data from various tags.
5. Downloaded the posters of movies using requests.
6. Used Tweepy to post the data on X (Twitter).

Note: To get the credentials related to X (Twitter), you can visit the developer dashboard of X. You can easily find tutorials on YouTube.

I am going to post the website image. This is how it looks, as shown below:

Rotten Tomatoes Website

I will share the GitHub code repository and Git.

Before going to the code please install some packages as given below:

pip install requests pandas beautifulsoup4

I am posting the code below, which extract the data from Rotten Tomatoes.

In the code below, please comment on lines 9 and 80. This code is for X (Twitter), and we need to set up the API credentials and write the Twitter posting module.

Now, let’s proceed with the X (Twitter) API setup:

  1. Create a Twitter developer account at Twitter Developer.
  2. Create a new app and note down the API key, API secret key, access token, and access token secret.
  3. Create a config_tweet.ini file in the project directory with the following format:
[Twitter]
api_key = YOUR_API_KEY
api_secret = YOUR_API_SECRET
acess_token = YOUR_ACCESS_TOKEN
acess_secret_token = YOUR_ACCESS_SECRET_TOKEN
bearer_token = YOUR_BEARER_TOKEN

After that, you can follow the post_tweet_v2.py code as mentioned below. You can uncomment lines 9 and 80 in the rotten_tomatoes.py code after completing the post_tweet_v2.py code.

pip install tweepy configparser

After completing the post_tweet_v2.py code, we can now run the rotten_tomatoes.py code. You can see the output as shown below:

Output of rotten_tomatoes.py

After getting Tweeted!, you can visit to the website and you can observe that your data has been posted. If you are facing any issue, please drop an email on shoebahmed370@gmail.com or shoebahmed370@outlook.com or you can connect me on LinkedIn : https://www.linkedin.com/in/shoeb-ahmed-97211211a/

As you can see the X(Twitter) output below:

X (Twitter) Post from Automations

I am attaching the Github repository for entire project which I publish:

Connect with me on LinkedIn and Twitter for freelance work opportunities in web scraping and Python automation. I’m open to collaborations and new projects!

If you found this article helpful and would like to support my work, consider making a donation via PayPal.

Thank you for reading!

--

--