Skip to main content

Unfollows accounts from a provided list on Instagram, with influencer filtering and live logging.

Project description

insta-pruner

PyPI version Python License: MIT

A Python library to automatically unfollow non-followers on Instagram, with influencer filtering and live logging.

Connects to your already-open, logged-in Chrome browser — no credentials stored, no login automation.


📦 Installation

pip install insta-pruner

🚀 Quick Start

Using a file

from insta_pruner import Pruner

pruner = Pruner(
    usernames_file="non_followers.txt",
    threshold=5000,
    inactive_months=6
)
pruner.run()

Using a list directly

from insta_pruner import Pruner

pruner = Pruner(
    usernames=["user1", "user2", "user3"],
    threshold=3000,
    inactive_months=3
)
pruner.run()

⚙️ Parameters

Parameter Type Default Description
usernames_file str None Path to .txt file with one username per line
usernames list None Pass usernames directly as a Python list
threshold int 5000 Accounts with ≥ this many followers are kept (influencer filter)
inactive_months int 6 Unfollow if no post or reel within this many months
unfollowed_log str unfollowed.txt File to log unfollowed accounts (appended, never overwritten)
kept_log str kept_following.txt File to log kept accounts (appended, never overwritten)
debugging_port int 9222 Chrome remote debugging port
pause_before_check int 4 Seconds to wait for each profile page to load
pause_between_users int 2 Seconds to wait between processing each user

Either usernames_file or usernames must be provided. If both are given, usernames takes priority.


💻 Before Running

You must start Chrome with remote debugging enabled so the library can connect to your logged-in session.

PowerShell:

Start-Process "C:\Program Files\Google\Chrome\Application\chrome.exe" -ArgumentList "--remote-debugging-port=9222", "--user-data-dir=C:\chrome-debug"

CMD:

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\chrome-debug"

macOS:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug

Then log in to Instagram in that Chrome window, and run your Python script.


📏 Unfollow Rules

The usernames list is expected to be non-followers (people who don’t follow you back). The library then applies:

  • Influencer filter — accounts with followers ≥ threshold are always kept
  • Inactivity filter — accounts with no posts or reels in the last inactive_months are unfollowed
  • Both posts (/p/) and reels (/reel/) are checked for last activity

📄 Log Files

Both log files are appended to on every run — previous data is never deleted. Each run is separated by a clear divider:

# UNFOLLOWED ACCOUNTS
# ===========================================================================
# Run started 2026-06-14 19:00:00
# ===========================================================================
# username                  followers   last_active   reason
# ---------------------------------------------------------------------------
@some_account                      320  2023-05-10    followers < 5,000 | last active 2023-05-10 (inactive)

# ===========================================================================
# NEW RUN — 2026-06-15 10:00:00
# ===========================================================================
# username                  followers   last_active   reason
# ---------------------------------------------------------------------------
@another_account                   150  N/A           followers < 5,000 | no posts/reels found

⚠️ Notes

  • Chrome must be open and logged in to Instagram before calling pruner.run()
  • Instagram may rate-limit your account if you process too many users too quickly — increase pause_between_users if needed
  • Private accounts with hidden posts/reels will show last activity as N/A and will be unfollowed if below the threshold
  • This library uses Selenium to automate browser actions — use responsibly

🧑‍💻 Author

Rahul S Rgithub.com/officialsrrahul

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

insta_pruner-0.1.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

insta_pruner-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file insta_pruner-0.1.2.tar.gz.

File metadata

  • Download URL: insta_pruner-0.1.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for insta_pruner-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f0f91b5bebd02009525691dfe54b24101817b165165bdedad121d5253695ad27
MD5 403f31bf8ea9f1f468e6c47a8937bb6c
BLAKE2b-256 dbe3ecef6fe8579b7e3661a7b161e7912797a8dda3569ef4b36f662ad2fcb0ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for insta_pruner-0.1.2.tar.gz:

Publisher: publish.yml on officialsrrahul/insta_pruner_package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file insta_pruner-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: insta_pruner-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for insta_pruner-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1efa9eee82c7e12a6b43df2b79871748579b6768dc3628a28fb78aaea0c2179
MD5 f55466ccd239a758552a249b53c99072
BLAKE2b-256 0142f112188daa301a40e0c1a34c0c2a12a7c21ac1e8931a672338e9562a5c5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for insta_pruner-0.1.2-py3-none-any.whl:

Publisher: publish.yml on officialsrrahul/insta_pruner_package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page