Chanakya AI Intelligent Solutions for a Smarter Future

How I Unliked 100000+ Instagram Posts with Python

By • July 22, 2025

 


🔁 How I Unliked Thousands of Instagram Posts Using Python — A Journey Through Automation and Accountability

“With great power comes great responsibility.” — Uncle Ben


📌 Introduction

Social media is a powerful tool. But sometimes, our digital habits don't align with our values, goals, or beliefs. Like many, I used Instagram extensively — liking posts, reels, and photos for years. Recently, I felt the need to clean up my digital footprint, especially the likes I had left on reels and posts that no longer reflected who I am today.

So, I decided to automate the process of unliking everything.

This blog walks you through the technical implementation, challenges, and even the ethical thoughts I had — including the concept of Gunah-e-Jariyah (a continuous sin in Islam) and how automation became a way to digitally cleanse that.


🔧 Why Not Manually?

Instagram doesn’t let you view or manage all your likes in one place. Manually scrolling through hundreds (or thousands) of posts and unliking each one is slow, tedious, and — let’s face it — frustrating.

Automation was the only sane option.


🧠 Ethical Motivation: Gunah-e-Jariyah (Ongoing Sin)

In Islam, Gunah-e-Jariyah refers to sins that continue to affect others even after you've stopped committing them — like spreading inappropriate content, endorsing harmful behavior, or sharing something misleading.

If you've ever liked or shared a questionable post that continues to influence others because your name appears under "liked by", that could fall under this category.
That realization hit hard. I knew I had to act.


🖥️ The Technical Plan

Tools I Used:


💻 The Code (Async Script)

Here's the script I used to automate the unliking process asynchronously, using Python and aiohttp:

import aiohttp
import asyncio
import pandas as pd

COOKIE = {
    'sessionid': 'your_session_id_here',  # replace with yours
    # Add additional cookies if necessary
}

HEADERS = {
    'user-agent': 'Mozilla/5.0',
    'referer': 'https://www.instagram.com/',
    'x-csrftoken': COOKIE.get('csrftoken'),
}

async def unlike_post(session, media_id, url):
    try:
        unlike_url = f"https://www.instagram.com/web/likes/{media_id}/unlike/"
        async with session.post(unlike_url) as response:
            if response.status == 200:
                print(f"✅ Unliked post {media_id}\n URL: {url}")
            else:
                print(f"⚠️ Error on {url}: {response.status}")
    except Exception as e:
        print(f"❌ Exception on {url}: {str(e)}")

async def main():
    df = pd.read_csv("liked_posts.csv")
    media_ids = df['media_id'].tolist()
    urls = df['url'].tolist()

    async with aiohttp.ClientSession(cookies=COOKIE, headers=HEADERS) as session:
        tasks = [
            unlike_post(session, media_id, url)
            for media_id, url in zip(media_ids, urls)
        ]
        await asyncio.gather(*tasks)

asyncio.run(main())

🚧 Common Errors


🧠 Lessons Learned

  1. Automation saves time, but it comes with risk — especially when dealing with cookies or private data.

  2. Async programming is powerful. I could batch-process hundreds of posts within seconds.

  3. Digital hygiene matters. Just like we clean our physical surroundings, cleaning our online presence is important too.

  4. Intentions matter. Unliking what no longer represents your values can prevent it from continuing to influence others.


⚠️ Disclaimer

Automating Instagram actions is against their Terms of Service.
This guide is for educational purposes only. Proceed at your own risk.


🙏 Final Words

If you've ever felt the need to start fresh on social media, this is one way to take control of your digital legacy. Whether you're doing it for religious reasons, mental clarity, or just decluttering — automation can help you get there faster.

And remember: it’s not just about removing likes.
It’s about reclaiming your influence and making sure your digital self reflects your real values.


💬 Need Help?

Have questions or want the script set up for your case?
Drop a comment below, reach out via GitHub, or DM me — happy to help others take back their timeline!