This bot scrapes memes from random subreddits and posts them to Instagram. It uses PRAW to scrape memes from Reddit and instabot to post memes to Instagram.
- Python 3.8 or higher
- pip
- virtualenv
- Instagram account
- Reddit account
- Clone the repository and navigate into the directory:
git clone https://github.com/samarth641/Reddit2Insta.git
- Install the required modules by Running this code In terminal:
pip install -r requirements.txt
-
Create a Reddit application and a corresponding client ID and client secret. Instructions can be found Here.
-
Create an Instagram account and generate an API key. You can skip this step and only use your instagram account username and password as we are only using that to connect to
InstagramAPI
Documentation Here. -
Go to
.env
file in the root of the directory and add the following variables with your own credentials:
REDDIT_CLIENT_ID=<your_reddit_client_id>
REDDIT_CLIENT_SECRET=<your_reddit_client_secret>
REDDIT_USERNAME=<your_reddit_username>
REDDIT_PASSWORD=<your_reddit_password>
REDDIT_USER_AGENT=<your_reddit_user_agent>
INSTA_USERNAME=<your_instagram_username>
INSTA_PASSWORD=<your_instagram_password>
To change the subreddits that the bot scrapes memes from, edit the subreddits variable in the reddit2insta.py file. Add or remove subreddits as needed, and separate them by commas. For example:
subreddits = ['subreddit1', 'subreddit2', 'subreddit3', 'subreddit']
Read the reddit2insta.py file to modify the square background color used to make images comply with Instagram's picture rules. To alter the fill color to any RGB color, go to Line 51 where we define the function to generate a square. You can find the RGB color code for any color from Here
For example:
def make_square(im, min_size=1080, fill_color=(0, 0, 0, 0)):
To
def make_square(im, min_size=1080, fill_color=(255, 255, 255, 0)):
- Run the bot:
python reddit2insta.py
subreddits
: A list of subreddits to scrape memes from. Replace the default subreddits with your own.directory
: The directory where the downloaded memes will be saved.posted_memes.json
: A JSON file that keeps track of the memes that have been posted to Instagram.
Contributions are welcome! Please open an issue or pull request for any changes you would like to make.
This project is licensed under the MIT License. See the LICENSE
file for more information.